fix(ios): call PictureInPicture callbacks with native controls (#3603)

* fix(ios): call PictureInPictureStatusChanged callback with native controls

We add RCTPlayerObserver as playerViewController delegate to be notified with PiP lifecycle
should partially fix #3602

* fix(ios): call onRestoreUserInterfaceForPictureInPictureStop callback with native controls

should partially fix #3602
This commit is contained in:
Gaëtan Kueny
2024-04-04 15:08:48 +02:00
committed by GitHub
parent 2a858df8bc
commit 051e884c8f
2 changed files with 55 additions and 2 deletions

View File

@@ -128,6 +128,18 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
onPictureInPictureStatusChanged?(["isActive": NSNumber(value: false)])
}
func handlePictureInPictureEnter() {
onPictureInPictureStatusChanged?(["isActive": NSNumber(value: true)])
}
func handlePictureInPictureExit() {
onPictureInPictureStatusChanged?(["isActive": NSNumber(value: false)])
}
func handleRestoreUserInterfaceForPictureInPictureStop() {
onRestoreUserInterfaceForPictureInPictureStop?([:])
}
func isPipEnabled() -> Bool {
return _pictureInPictureEnabled
}
@@ -606,7 +618,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
@objc
func setRestoreUserInterfaceForPIPStopCompletionHandler(_ restore: Bool) {
#if os(iOS)
_pip?.setRestoreUserInterfaceForPIPStopCompletionHandler(restore)
if _pip != nil {
_pip?.setRestoreUserInterfaceForPIPStopCompletionHandler(restore)
} else {
_playerObserver.setRestoreUserInterfaceForPIPStopCompletionHandler(restore)
}
#endif
}