From b05201a9fab03aff15463e44877e9154c8afa68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Lewandowski?= Date: Thu, 22 Aug 2024 10:30:23 +0200 Subject: [PATCH] fix crash on source change, if the app was put in bg beforehand (#4074) --- ios/Video/RCTVideo.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 325a06f1..bd1a916e 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -488,8 +488,18 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH NowPlayingInfoCenterManager.shared.registerPlayer(player: _player!) } } else { + if #available(iOS 16.0, *) { + // This feature caused crashes, if the app was put in bg, before the source change + // https://github.com/TheWidlarzGroup/react-native-video/issues/3900 + self._playerViewController?.allowsVideoFrameAnalysis = false + } + _player?.replaceCurrentItem(with: playerItem) + if #available(iOS 16.0, *) { + self._playerViewController?.allowsVideoFrameAnalysis = true + } + // later we can just call "updateNowPlayingInfo: NowPlayingInfoCenterManager.shared.updateNowPlayingInfo() }