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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user