fix(ios): remove pip check for other platforms (#3991)

* fix(ios): remove pip check for other platforms

* Update ios/Video/RCTVideo.swift
This commit is contained in:
Krzysztof Moch 2024-07-11 12:54:54 +02:00 committed by GitHub
parent 111a5d2163
commit 40a72825e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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