Skip to content

Commit

Permalink
fix(ios): remove pip check for other platforms (#3991)
Browse files Browse the repository at this point in the history
* fix(ios): remove pip check for other platforms

* Update ios/Video/RCTVideo.swift
  • Loading branch information
KrzysztofMoch authored Jul 11, 2024
1 parent 111a5d2 commit 40a7282
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 40a7282

Please sign in to comment.