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