Add option for listening to fullscreen player events
This commit is contained in:
parent
2ef7c3024e
commit
6d05b7bf79
@ -458,18 +458,21 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty";
|
|||||||
if( viewController )
|
if( viewController )
|
||||||
{
|
{
|
||||||
_presentingViewController = viewController;
|
_presentingViewController = viewController;
|
||||||
|
[_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerWillPresent" body:@{@"target": self.reactTag}];
|
||||||
[viewController presentViewController:_playerViewController animated:true completion:^{
|
[viewController presentViewController:_playerViewController animated:true completion:^{
|
||||||
_playerViewController.showsPlaybackControls = YES;
|
_playerViewController.showsPlaybackControls = YES;
|
||||||
_fullScreenPlayerPresented = fullscreen;
|
_fullScreenPlayerPresented = fullscreen;
|
||||||
|
[_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidPresent" body:@{@"target": self.reactTag}];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
[_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerWillDismiss" body:@{@"target": self.reactTag}];
|
||||||
[_presentingViewController dismissViewControllerAnimated:true completion:^{
|
[_presentingViewController dismissViewControllerAnimated:true completion:^{
|
||||||
_fullScreenPlayerPresented = fullscreen;
|
_fullScreenPlayerPresented = fullscreen;
|
||||||
_presentingViewController = nil;
|
_presentingViewController = nil;
|
||||||
|
[_eventDispatcher sendInputEventWithName:@"onVideoFullscreenPlayerDidDismiss" body:@{@"target": self.reactTag}];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,11 @@ RCT_EXPORT_MODULE();
|
|||||||
@"onVideoError",
|
@"onVideoError",
|
||||||
@"onVideoProgress",
|
@"onVideoProgress",
|
||||||
@"onVideoSeek",
|
@"onVideoSeek",
|
||||||
@"onVideoEnd"
|
@"onVideoEnd",
|
||||||
|
@"onVideoFullscreenPlayerWillPresent",
|
||||||
|
@"onVideoFullscreenPlayerDidPresent",
|
||||||
|
@"onVideoFullscreenPlayerWillDismiss",
|
||||||
|
@"onVideoFullscreenPlayerDidDismiss"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
Video.js
36
Video.js
@ -29,6 +29,10 @@ export default class Video extends Component {
|
|||||||
this._onProgress = this._onProgress.bind(this);
|
this._onProgress = this._onProgress.bind(this);
|
||||||
this._onSeek = this._onSeek.bind(this);
|
this._onSeek = this._onSeek.bind(this);
|
||||||
this._onEnd = this._onEnd.bind(this);
|
this._onEnd = this._onEnd.bind(this);
|
||||||
|
this._onFullscreenPlayerWillPresent = this._onFullscreenPlayerWillPresent.bind(this);
|
||||||
|
this._onFullscreenPlayerDidPresent = this._onFullscreenPlayerDidPresent.bind(this);
|
||||||
|
this._onFullscreenPlayerWillDismiss = this._onFullscreenPlayerWillDismiss.bind(this);
|
||||||
|
this._onFullscreenPlayerDidDismiss = this._onFullscreenPlayerDidDismiss.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
setNativeProps(nativeProps) {
|
setNativeProps(nativeProps) {
|
||||||
@ -83,6 +87,30 @@ export default class Video extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onFullscreenPlayerWillPresent(event) {
|
||||||
|
if (this.props.onFullscreenPlayerWillPresent) {
|
||||||
|
this.props.onFullscreenPlayerWillPresent(event.nativeEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_onFullscreenPlayerDidPresent(event) {
|
||||||
|
if (this.props.onFullscreenPlayerWillPresent) {
|
||||||
|
this.props.onFullscreenPlayerDidPresent(event.nativeEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_onFullscreenPlayerWillDismiss(event) {
|
||||||
|
if (this.props.onFullscreenPlayerWillPresent) {
|
||||||
|
this.props.onFullscreenPlayerWillDismiss(event.nativeEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_onFullscreenPlayerDidDismiss(event) {
|
||||||
|
if (this.props.onFullscreenPlayerDidDismiss) {
|
||||||
|
this.props.onFullscreenPlayerDidDismiss(event.nativeEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
source,
|
source,
|
||||||
@ -124,6 +152,10 @@ export default class Video extends Component {
|
|||||||
onVideoProgress: this._onProgress,
|
onVideoProgress: this._onProgress,
|
||||||
onVideoSeek: this._onSeek,
|
onVideoSeek: this._onSeek,
|
||||||
onVideoEnd: this._onEnd,
|
onVideoEnd: this._onEnd,
|
||||||
|
onVideoFullscreenPlayerWillPresent: this._onFullscreenPlayerWillPresent,
|
||||||
|
onVideoFullscreenPlayerDidPresent: this._onFullscreenPlayerDidPresent,
|
||||||
|
onVideoFullscreenPlayerWillDismiss: this._onFullscreenPlayerWillDismiss,
|
||||||
|
onVideoFullscreenPlayerDidDismiss: this._onFullscreenPlayerDidDismiss,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -157,6 +189,10 @@ Video.propTypes = {
|
|||||||
onProgress: PropTypes.func,
|
onProgress: PropTypes.func,
|
||||||
onSeek: PropTypes.func,
|
onSeek: PropTypes.func,
|
||||||
onEnd: PropTypes.func,
|
onEnd: PropTypes.func,
|
||||||
|
onFullscreenPlayerWillPresent: PropTypes.func,
|
||||||
|
onFullscreenPlayerDidPresent: PropTypes.func,
|
||||||
|
onFullscreenPlayerWillDismiss: PropTypes.func,
|
||||||
|
onFullscreenPlayerDidDismiss: PropTypes.func,
|
||||||
|
|
||||||
/* Required by react-native */
|
/* Required by react-native */
|
||||||
scaleX: React.PropTypes.number,
|
scaleX: React.PropTypes.number,
|
||||||
|
Loading…
Reference in New Issue
Block a user