From bf810386b9ee1aed579b24adffb02f4acfa413db Mon Sep 17 00:00:00 2001 From: Dawid Wyrkowski Date: Sun, 13 Jul 2025 17:54:38 +0200 Subject: [PATCH] fix(ios): add audiovisualBackgroundPlaybackPolicy (#4570) --- ios/Video/RCTVideo.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 47a5d3e0..ac4232ce 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -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() }