forked from TheWidlarzGroup/react-native-video
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f7a981
commit 7fa423a
Showing
6 changed files
with
107 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// RCTPlayerDelegate.swift | ||
// | ||
import UIKit | ||
import AVKit | ||
import AVFoundation | ||
|
||
@available(iOS 9.0, *) | ||
class RCTPlayerDelegate: NSObject, AVPlayerViewControllerDelegate { | ||
|
||
private var _onPictureInPictureStatusChanged: RCTDirectEventBlock? | ||
private var _onVideoFullscreenPlayerWillPresent: RCTDirectEventBlock? | ||
private var _onVideoFullscreenPlayerWillDismiss: RCTDirectEventBlock? | ||
private var _onVideoFullscreenPlayerDidDismiss: RCTDirectEventBlock? | ||
|
||
init(_ onPictureInPictureStatusChanged: RCTDirectEventBlock?, _ onVideoFullscreenPlayerWillPresent: RCTDirectEventBlock?, _ onVideoFullscreenPlayerWillDismiss: RCTDirectEventBlock?, _ onVideoFullscreenPlayerDidDismiss: RCTDirectEventBlock?) { | ||
_onPictureInPictureStatusChanged = onPictureInPictureStatusChanged | ||
_onVideoFullscreenPlayerWillPresent = onVideoFullscreenPlayerWillPresent | ||
_onVideoFullscreenPlayerWillDismiss = onVideoFullscreenPlayerWillDismiss | ||
_onVideoFullscreenPlayerDidDismiss = onVideoFullscreenPlayerDidDismiss | ||
} | ||
|
||
func playerViewControllerDidStartPictureInPicture(_ playerViewController: AVPlayerViewController) { | ||
|
||
_onPictureInPictureStatusChanged!([ "isActive": NSNumber(value: true) ]) | ||
|
||
} | ||
|
||
func playerViewControllerDidStopPictureInPicture(_ playerViewController: AVPlayerViewController) { | ||
|
||
_onPictureInPictureStatusChanged!([ "isActive": NSNumber(value: false) ]) | ||
|
||
} | ||
|
||
func playerViewController(_ playerViewController: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator: UIViewControllerTransitionCoordinator) { | ||
|
||
_onVideoFullscreenPlayerWillPresent?([:]) | ||
|
||
} | ||
|
||
func playerViewController(_ playerViewController: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) { | ||
coordinator.animate(alongsideTransition: nil, completion: { _ in | ||
self._onVideoFullscreenPlayerDidDismiss?([:]) | ||
}) | ||
|
||
_onVideoFullscreenPlayerWillDismiss?([:]) | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters