fix: prevent audiovisualBackgroundPlaybackPolicy crash (#4763)
This commit is contained in:
@@ -573,14 +573,15 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
ReactNativeVideoManager.shared.onInstanceCreated(id: instanceId, player: _player as Any)
|
ReactNativeVideoManager.shared.onInstanceCreated(id: instanceId, player: _player as Any)
|
||||||
|
|
||||||
_player!.replaceCurrentItem(with: playerItem)
|
_player!.replaceCurrentItem(with: playerItem)
|
||||||
|
#if !os(tvOS) && !os(visionOS)
|
||||||
if #available(iOS 15.0, *) {
|
if #available(iOS 15.0, *) {
|
||||||
if _playInBackground {
|
if _playInBackground {
|
||||||
_player!.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
|
_player!.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
|
||||||
} else {
|
} else {
|
||||||
_player!.audiovisualBackgroundPlaybackPolicy = .automatic
|
_player!.audiovisualBackgroundPlaybackPolicy = .automatic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
if _showNotificationControls {
|
if _showNotificationControls {
|
||||||
// We need to register player after we set current item and only for init
|
// We need to register player after we set current item and only for init
|
||||||
@@ -601,13 +602,15 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if #available(iOS 15.0, *) {
|
#if !os(tvOS) && !os(visionOS)
|
||||||
if _playInBackground {
|
if #available(iOS 15.0, *) {
|
||||||
_player!.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
|
if _playInBackground {
|
||||||
} else {
|
_player!.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
|
||||||
_player!.audiovisualBackgroundPlaybackPolicy = .automatic
|
} else {
|
||||||
|
_player!.audiovisualBackgroundPlaybackPolicy = .automatic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
// later we can just call "updateNowPlayingInfo:
|
// later we can just call "updateNowPlayingInfo:
|
||||||
NowPlayingInfoCenterManager.shared.updateNowPlayingInfo()
|
NowPlayingInfoCenterManager.shared.updateNowPlayingInfo()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user