fix(ios): add audiovisualBackgroundPlaybackPolicy (#4570)

This commit is contained in:
Dawid Wyrkowski
2025-07-13 17:54:38 +02:00
committed by GitHub
parent e77a12ebaa
commit bf810386b9

View File

@@ -574,6 +574,14 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
_player!.replaceCurrentItem(with: playerItem)
if #available(iOS 15.0, *) {
if _playInBackground {
_player!.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
} else {
_player!.audiovisualBackgroundPlaybackPolicy = .automatic
}
}
if _showNotificationControls {
// We need to register player after we set current item and only for init
NowPlayingInfoCenterManager.shared.registerPlayer(player: _player!)
@@ -592,6 +600,14 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
self._playerViewController?.allowsVideoFrameAnalysis = true
}
#endif
if #available(iOS 15.0, *) {
if _playInBackground {
_player!.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
} else {
_player!.audiovisualBackgroundPlaybackPolicy = .automatic
}
}
// later we can just call "updateNowPlayingInfo:
NowPlayingInfoCenterManager.shared.updateNowPlayingInfo()
}