From 40a72825e659c86999859ea2cead51b2752b4c79 Mon Sep 17 00:00:00 2001 From: Krzysztof Moch Date: Thu, 11 Jul 2024 12:54:54 +0200 Subject: [PATCH] fix(ios): remove pip check for other platforms (#3991) * fix(ios): remove pip check for other platforms * Update ios/Video/RCTVideo.swift --- ios/Video/RCTVideo.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 6767aed2..bf9e2d14 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -171,6 +171,14 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH return _pictureInPictureEnabled } + func isPipActive() -> Bool { + #if os(iOS) + return _pip?._pipController?.isPictureInPictureActive == true + #else + return false + #endif + } + func initPictureinPicture() { #if os(iOS) _pip = RCTPictureInPicture({ [weak self] in @@ -298,7 +306,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH @objc func applicationDidEnterBackground(notification _: NSNotification!) { let isExternalPlaybackActive = _player?.isExternalPlaybackActive ?? false - if !_playInBackground || isExternalPlaybackActive || _pip?._pipController?.isPictureInPictureActive == true { return } + if !_playInBackground || isExternalPlaybackActive || isPipActive() { return } // Needed to play sound in background. See https://developer.apple.com/library/ios/qa/qa1668/_index.html _playerLayer?.player = nil _playerViewController?.player = nil