2020-01-28 15:21:21 -07:00
import React , { Component } from 'react' ;
2017-08-04 12:53:53 -06:00
import PropTypes from 'prop-types' ;
2020-01-28 15:21:21 -07:00
import { StyleSheet , requireNativeComponent , NativeModules , View , ViewPropTypes , Image , Platform , UIManager , findNodeHandle , Dimensions } from 'react-native' ;
2016-06-22 07:52:12 -06:00
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource' ;
2018-06-12 22:04:15 -06:00
import TextTrackType from './TextTrackType' ;
2018-11-06 07:38:28 -07:00
import FilterType from './FilterType' ;
2016-01-31 20:35:18 -07:00
import VideoResizeMode from './VideoResizeMode.js' ;
2015-10-29 18:26:28 -06:00
const styles = StyleSheet . create ( {
base : {
overflow : 'hidden' ,
} ,
} ) ;
2018-11-06 07:38:28 -07:00
export { TextTrackType , FilterType } ;
2018-06-12 22:04:15 -06:00
2016-01-31 20:35:18 -07:00
export default class Video extends Component {
2015-10-29 18:26:28 -06:00
2016-12-05 14:57:35 -07:00
constructor ( props ) {
super ( props ) ;
this . state = {
2020-01-28 15:21:21 -07:00
showPoster : ! ! props . poster ,
androidFullScreen : false ,
videoContainerLayout _x : 0 ,
2020-02-22 11:56:31 -07:00
videoContainerLayout _y : 0 ,
2016-12-05 14:57:35 -07:00
} ;
2020-01-28 15:21:21 -07:00
this . getDimension ( ) ;
}
/ * *
* @ description this is will set the width and height needs to be considered for full screen
* /
getDimension ( ) {
if ( Dimensions . get ( 'window' ) . width < Dimensions . get ( 'window' ) . height ) {
this . width = Math . round ( Dimensions . get ( 'window' ) . height ) ;
this . height = Math . round ( Dimensions . get ( 'window' ) . width ) ;
}
else {
this . width = Math . round ( Dimensions . get ( 'window' ) . width ) ;
this . height = Math . round ( Dimensions . get ( 'window' ) . height ) ;
}
}
componentDidMount ( ) {
UIManager . measure ( findNodeHandle ( this . _videoContainer ) , ( x , y ) => {
this . setState ( {
videoContainerLayout _x : x ,
2020-02-22 11:56:31 -07:00
videoContainerLayout _y : y ,
} ) ;
} ) ;
2016-12-05 14:57:35 -07:00
}
2015-11-09 18:55:39 -07:00
setNativeProps ( nativeProps ) {
this . _root . setNativeProps ( nativeProps ) ;
}
2020-01-28 15:21:21 -07:00
2018-01-13 13:28:24 -07:00
toTypeString ( x ) {
switch ( typeof x ) {
2020-02-22 11:56:31 -07:00
case 'object' :
2020-01-28 15:21:21 -07:00
return x instanceof Date
? x . toISOString ( )
2018-01-13 13:28:24 -07:00
: JSON . stringify ( x ) ; // object, null
2020-02-22 11:56:31 -07:00
case 'undefined' :
return '' ;
2018-01-13 13:28:24 -07:00
default : // boolean, number, string
2020-01-28 15:21:21 -07:00
return x . toString ( ) ;
2018-01-13 13:28:24 -07:00
}
}
stringsOnlyObject ( obj ) {
const strObj = { } ;
Object . keys ( obj ) . forEach ( x => {
strObj [ x ] = this . toTypeString ( obj [ x ] ) ;
} ) ;
return strObj ;
}
2015-11-09 18:55:39 -07:00
2018-06-20 23:09:45 -06:00
seek = ( time , tolerance = 100 ) => {
2020-02-22 11:56:31 -07:00
if ( isNaN ( time ) ) { throw new Error ( 'Specified time is not a number' ) ; }
2020-01-28 15:21:21 -07:00
2018-06-20 23:09:45 -06:00
if ( Platform . OS === 'ios' ) {
this . setNativeProps ( {
seek : {
time ,
2020-02-22 11:56:31 -07:00
tolerance ,
} ,
2018-06-20 23:09:45 -06:00
} ) ;
} else {
this . setNativeProps ( { seek : time } ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2016-01-31 20:35:18 -07:00
2016-06-22 08:28:54 -06:00
presentFullscreenPlayer = ( ) => {
2016-03-31 12:36:39 -06:00
this . setNativeProps ( { fullscreen : true } ) ;
2016-06-22 08:28:54 -06:00
} ;
2016-03-31 12:36:39 -06:00
2016-06-22 08:28:54 -06:00
dismissFullscreenPlayer = ( ) => {
2016-04-01 03:12:50 -06:00
this . setNativeProps ( { fullscreen : false } ) ;
2016-06-22 08:28:54 -06:00
} ;
2016-04-01 03:12:50 -06:00
2018-11-06 07:38:28 -07:00
save = async ( options ? ) => {
2018-10-26 07:21:41 -06:00
return await NativeModules . VideoManager . save ( options , findNodeHandle ( this . _root ) ) ;
}
2018-11-26 15:23:04 -07:00
restoreUserInterfaceForPictureInPictureStopCompleted = ( restored ) => {
this . setNativeProps ( { restoreUserInterfaceForPIPStopCompletionHandler : restored } ) ;
2018-10-26 14:33:03 -06:00
} ;
2016-06-22 08:28:54 -06:00
_assignRoot = ( component ) => {
2016-01-31 20:35:18 -07:00
this . _root = component ;
2016-06-22 08:28:54 -06:00
} ;
2015-11-11 14:34:41 -07:00
2019-06-19 05:00:57 -06:00
_hidePoster = ( ) => {
2019-06-20 02:24:12 -06:00
if ( this . state . showPoster ) {
2020-01-28 15:21:21 -07:00
this . setState ( { showPoster : false } ) ;
2019-06-20 02:24:12 -06:00
}
2019-06-19 05:00:57 -06:00
}
2016-06-22 08:28:54 -06:00
_onLoadStart = ( event ) => {
2016-01-31 20:35:18 -07:00
if ( this . props . onLoadStart ) {
this . props . onLoadStart ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2015-11-17 20:15:07 -07:00
2016-06-22 08:28:54 -06:00
_onLoad = ( event ) => {
2019-06-20 02:24:12 -06:00
// Need to hide poster here for windows as onReadyForDisplay is not implemented
if ( Platform . OS === 'windows' ) {
this . _hidePoster ( ) ;
}
2016-01-31 20:35:18 -07:00
if ( this . props . onLoad ) {
this . props . onLoad ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2015-11-17 20:15:07 -07:00
2016-06-22 08:28:54 -06:00
_onError = ( event ) => {
2016-01-31 20:35:18 -07:00
if ( this . props . onError ) {
this . props . onError ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2015-11-17 20:15:07 -07:00
2016-06-22 08:28:54 -06:00
_onProgress = ( event ) => {
2016-01-31 20:35:18 -07:00
if ( this . props . onProgress ) {
this . props . onProgress ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2015-11-17 20:15:07 -07:00
2018-08-25 10:23:11 -06:00
_onBandwidthUpdate = ( event ) => {
if ( this . props . onBandwidthUpdate ) {
this . props . onBandwidthUpdate ( event . nativeEvent ) ;
}
2020-01-28 15:21:21 -07:00
} ;
2018-08-25 10:23:11 -06:00
2016-06-22 08:28:54 -06:00
_onSeek = ( event ) => {
2016-01-31 20:35:18 -07:00
if ( this . props . onSeek ) {
this . props . onSeek ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2015-11-17 20:15:07 -07:00
2016-06-22 08:28:54 -06:00
_onEnd = ( event ) => {
2016-01-31 20:35:18 -07:00
if ( this . props . onEnd ) {
this . props . onEnd ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2015-11-17 20:15:07 -07:00
2017-02-13 19:38:02 -07:00
_onTimedMetadata = ( event ) => {
if ( this . props . onTimedMetadata ) {
this . props . onTimedMetadata ( event . nativeEvent ) ;
}
} ;
2016-06-22 08:28:54 -06:00
_onFullscreenPlayerWillPresent = ( event ) => {
2020-02-22 11:56:31 -07:00
Platform . OS === 'android' && this . setState ( { androidFullScreen : true } ) ;
2016-03-31 13:35:10 -06:00
if ( this . props . onFullscreenPlayerWillPresent ) {
this . props . onFullscreenPlayerWillPresent ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2016-03-31 13:35:10 -06:00
2016-06-22 08:28:54 -06:00
_onFullscreenPlayerDidPresent = ( event ) => {
2016-03-31 13:40:49 -06:00
if ( this . props . onFullscreenPlayerDidPresent ) {
2016-03-31 13:35:10 -06:00
this . props . onFullscreenPlayerDidPresent ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2016-03-31 13:35:10 -06:00
2016-06-22 08:28:54 -06:00
_onFullscreenPlayerWillDismiss = ( event ) => {
2020-02-22 11:56:31 -07:00
Platform . OS === 'android' && this . setState ( { androidFullScreen : false } ) ;
2016-03-31 13:40:49 -06:00
if ( this . props . onFullscreenPlayerWillDismiss ) {
2016-03-31 13:35:10 -06:00
this . props . onFullscreenPlayerWillDismiss ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2016-03-31 13:35:10 -06:00
2016-06-22 08:28:54 -06:00
_onFullscreenPlayerDidDismiss = ( event ) => {
2016-03-31 13:35:10 -06:00
if ( this . props . onFullscreenPlayerDidDismiss ) {
this . props . onFullscreenPlayerDidDismiss ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2015-11-17 20:15:07 -07:00
2016-06-22 08:28:54 -06:00
_onReadyForDisplay = ( event ) => {
2019-11-26 12:40:03 -07:00
if ( ! this . props . audioOnly ) {
this . _hidePoster ( ) ;
}
2020-02-22 11:56:31 -07:00
2016-04-28 06:42:44 -06:00
if ( this . props . onReadyForDisplay ) {
this . props . onReadyForDisplay ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2016-04-28 06:42:44 -06:00
2016-06-22 08:28:54 -06:00
_onPlaybackStalled = ( event ) => {
2016-04-28 06:42:44 -06:00
if ( this . props . onPlaybackStalled ) {
this . props . onPlaybackStalled ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2016-04-28 06:42:44 -06:00
2016-06-22 08:28:54 -06:00
_onPlaybackResume = ( event ) => {
2016-04-28 06:42:44 -06:00
if ( this . props . onPlaybackResume ) {
this . props . onPlaybackResume ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2016-04-28 06:42:44 -06:00
2016-06-22 08:28:54 -06:00
_onPlaybackRateChange = ( event ) => {
2016-04-28 06:42:44 -06:00
if ( this . props . onPlaybackRateChange ) {
this . props . onPlaybackRateChange ( event . nativeEvent ) ;
}
2016-06-22 08:28:54 -06:00
} ;
2020-01-28 15:21:21 -07:00
2018-09-13 06:06:12 -06:00
_onExternalPlaybackChange = ( event ) => {
if ( this . props . onExternalPlaybackChange ) {
this . props . onExternalPlaybackChange ( event . nativeEvent ) ;
}
}
2016-04-28 06:42:44 -06:00
2017-01-11 05:51:45 -07:00
_onAudioBecomingNoisy = ( ) => {
if ( this . props . onAudioBecomingNoisy ) {
this . props . onAudioBecomingNoisy ( ) ;
}
} ;
2018-11-26 15:23:04 -07:00
_onPictureInPictureStatusChanged = ( event ) => {
if ( this . props . onPictureInPictureStatusChanged ) {
this . props . onPictureInPictureStatusChanged ( event . nativeEvent ) ;
2018-10-26 14:33:03 -06:00
}
} ;
2018-11-26 15:23:04 -07:00
_onRestoreUserInterfaceForPictureInPictureStop = ( event ) => {
2020-01-28 15:21:21 -07:00
if ( this . props . onRestoreUserInterfaceForPictureInPictureStop ) {
2018-11-26 15:23:04 -07:00
this . props . onRestoreUserInterfaceForPictureInPictureStop ( ) ;
2018-10-26 14:33:03 -06:00
}
} ;
2017-01-11 05:51:45 -07:00
_onAudioFocusChanged = ( event ) => {
if ( this . props . onAudioFocusChanged ) {
this . props . onAudioFocusChanged ( event . nativeEvent ) ;
}
} ;
_onBuffer = ( event ) => {
if ( this . props . onBuffer ) {
this . props . onBuffer ( event . nativeEvent ) ;
}
} ;
2019-02-18 04:17:20 -07:00
getViewManagerConfig = viewManagerName => {
2019-02-18 23:38:09 -07:00
if ( ! NativeModules . UIManager . getViewManagerConfig ) {
return NativeModules . UIManager [ viewManagerName ] ;
2019-02-18 04:17:20 -07:00
}
2019-02-18 23:38:09 -07:00
return NativeModules . UIManager . getViewManagerConfig ( viewManagerName ) ;
2019-02-18 04:17:20 -07:00
} ;
2015-10-29 18:26:28 -06:00
render ( ) {
2016-06-22 07:52:12 -06:00
const resizeMode = this . props . resizeMode ;
const source = resolveAssetSource ( this . props . source ) || { } ;
2020-02-22 11:56:31 -07:00
const shouldCache = ! source . _ _packager _asset ;
2015-10-29 18:26:28 -06:00
2017-01-28 18:46:30 -07:00
let uri = source . uri || '' ;
2015-10-29 18:26:28 -06:00
if ( uri && uri . match ( /^\// ) ) {
2016-01-31 20:35:18 -07:00
uri = ` file:// ${ uri } ` ;
2015-10-29 18:26:28 -06:00
}
2020-01-28 15:21:21 -07:00
2019-02-18 22:36:17 -07:00
if ( ! uri ) {
console . warn ( 'Trying to load empty source.' ) ;
}
2015-10-29 18:26:28 -06:00
const isNetwork = ! ! ( uri && uri . match ( /^https?:/ ) ) ;
2018-01-31 05:23:19 -07:00
const isAsset = ! ! ( uri && uri . match ( /^(assets-library|ipod-library|file|content|ms-appx|ms-appdata):/ ) ) ;
2015-10-29 18:26:28 -06:00
let nativeResizeMode ;
2019-02-18 04:17:20 -07:00
const RCTVideoInstance = this . getViewManagerConfig ( 'RCTVideo' ) ;
2015-10-29 18:26:28 -06:00
if ( resizeMode === VideoResizeMode . stretch ) {
2019-02-18 04:17:20 -07:00
nativeResizeMode = RCTVideoInstance . Constants . ScaleToFill ;
2015-10-29 18:26:28 -06:00
} else if ( resizeMode === VideoResizeMode . contain ) {
2019-02-18 04:17:20 -07:00
nativeResizeMode = RCTVideoInstance . Constants . ScaleAspectFit ;
2015-10-29 18:26:28 -06:00
} else if ( resizeMode === VideoResizeMode . cover ) {
2019-02-18 04:17:20 -07:00
nativeResizeMode = RCTVideoInstance . Constants . ScaleAspectFill ;
2015-10-29 18:26:28 -06:00
} else {
2019-02-18 04:17:20 -07:00
nativeResizeMode = RCTVideoInstance . Constants . ScaleNone ;
2015-10-29 18:26:28 -06:00
}
2015-11-03 21:27:38 -07:00
const nativeProps = Object . assign ( { } , this . props ) ;
2015-10-29 18:26:28 -06:00
Object . assign ( nativeProps , {
2016-01-31 20:35:18 -07:00
style : [ styles . base , nativeProps . style ] ,
2015-10-29 18:26:28 -06:00
resizeMode : nativeResizeMode ,
src : {
2016-01-31 20:35:18 -07:00
uri ,
2015-10-29 18:26:28 -06:00
isNetwork ,
isAsset ,
2019-01-24 05:15:58 -07:00
shouldCache ,
2017-01-28 18:46:30 -07:00
type : source . type || '' ,
2016-09-14 05:28:06 -06:00
mainVer : source . mainVer || 0 ,
patchVer : source . patchVer || 0 ,
2020-02-22 11:56:31 -07:00
requestHeaders : source . headers ? this . stringsOnlyObject ( source . headers ) : { } ,
2015-10-29 18:26:28 -06:00
} ,
2015-11-11 14:34:41 -07:00
onVideoLoadStart : this . _onLoadStart ,
2015-10-29 18:26:28 -06:00
onVideoLoad : this . _onLoad ,
2015-11-11 14:34:41 -07:00
onVideoError : this . _onError ,
2015-10-29 18:26:28 -06:00
onVideoProgress : this . _onProgress ,
2015-11-11 14:34:41 -07:00
onVideoSeek : this . _onSeek ,
2015-10-29 18:26:28 -06:00
onVideoEnd : this . _onEnd ,
2017-01-11 05:51:45 -07:00
onVideoBuffer : this . _onBuffer ,
2018-11-01 10:11:57 -06:00
onVideoBandwidthUpdate : this . _onBandwidthUpdate ,
2017-02-13 19:38:02 -07:00
onTimedMetadata : this . _onTimedMetadata ,
2018-07-12 22:48:58 -06:00
onVideoAudioBecomingNoisy : this . _onAudioBecomingNoisy ,
2018-10-07 16:59:10 -06:00
onVideoExternalPlaybackChange : this . _onExternalPlaybackChange ,
2016-03-31 13:35:10 -06:00
onVideoFullscreenPlayerWillPresent : this . _onFullscreenPlayerWillPresent ,
onVideoFullscreenPlayerDidPresent : this . _onFullscreenPlayerDidPresent ,
onVideoFullscreenPlayerWillDismiss : this . _onFullscreenPlayerWillDismiss ,
onVideoFullscreenPlayerDidDismiss : this . _onFullscreenPlayerDidDismiss ,
2016-04-28 06:42:44 -06:00
onReadyForDisplay : this . _onReadyForDisplay ,
onPlaybackStalled : this . _onPlaybackStalled ,
onPlaybackResume : this . _onPlaybackResume ,
onPlaybackRateChange : this . _onPlaybackRateChange ,
2017-01-11 05:51:45 -07:00
onAudioFocusChanged : this . _onAudioFocusChanged ,
onAudioBecomingNoisy : this . _onAudioBecomingNoisy ,
2018-11-26 15:23:04 -07:00
onPictureInPictureStatusChanged : this . _onPictureInPictureStatusChanged ,
onRestoreUserInterfaceForPictureInPictureStop : this . _onRestoreUserInterfaceForPictureInPictureStop ,
2015-10-29 18:26:28 -06:00
} ) ;
2018-08-04 15:28:33 -06:00
const posterStyle = {
... StyleSheet . absoluteFillObject ,
resizeMode : this . props . posterResizeMode || 'contain' ,
} ;
2016-12-05 14:57:35 -07:00
2020-01-28 15:21:21 -07:00
//androidFullScreen property will only impact on android. It will be always false for iOS.
const videoStyle = this . state . androidFullScreen ? {
position : 'absolute' ,
top : 0 ,
left : 0 ,
width : this . width ,
height : this . height ,
backgroundColor : '#ffffff' ,
2020-02-22 11:56:31 -07:00
justifyContent : 'center' ,
2020-01-28 15:21:21 -07:00
zIndex : 99999 ,
marginTop : - 1 * ( this . state . videoContainerLayout _y ? parseFloat ( this . state . videoContainerLayout _y ) : 0 ) , //margin: 0 - is not working properly. So, updated all the margin individually with 0.
2020-02-22 11:56:31 -07:00
marginLeft : - 1 * ( this . state . videoContainerLayout _x ? parseFloat ( this . state . videoContainerLayout _x ) : 0 ) ,
} : { } ;
2020-01-28 15:21:21 -07:00
2015-11-09 18:55:39 -07:00
return (
2020-02-22 11:56:31 -07:00
< View ref = { ( videoContainer ) => {
this . _videoContainer = videoContainer ;
return videoContainer ;
} } style = { [ nativeProps . style , videoStyle ] } >
2019-06-19 03:39:35 -06:00
< RCTVideo
ref = { this . _assignRoot }
{ ... nativeProps }
style = { StyleSheet . absoluteFill }
/ >
2019-06-19 05:00:57 -06:00
{ this . state . showPoster && (
2019-06-19 07:19:06 -06:00
< Image style = { posterStyle } source = { { uri : this . props . poster } } / >
2019-06-19 03:39:35 -06:00
) }
< / V i e w >
2015-11-09 18:55:39 -07:00
) ;
2015-10-29 18:26:28 -06:00
}
}
Video . propTypes = {
2018-11-06 07:38:28 -07:00
filter : PropTypes . oneOf ( [
2020-01-28 15:21:21 -07:00
FilterType . NONE ,
FilterType . INVERT ,
FilterType . MONOCHROME ,
FilterType . POSTERIZE ,
FilterType . FALSE ,
FilterType . MAXIMUMCOMPONENT ,
FilterType . MINIMUMCOMPONENT ,
FilterType . CHROME ,
FilterType . FADE ,
FilterType . INSTANT ,
FilterType . MONO ,
FilterType . NOIR ,
FilterType . PROCESS ,
FilterType . TONAL ,
FilterType . TRANSFER ,
2020-02-22 11:56:31 -07:00
FilterType . SEPIA ,
2018-11-06 07:38:28 -07:00
] ) ,
2018-12-13 20:30:38 -07:00
filterEnabled : PropTypes . bool ,
2015-10-29 18:26:28 -06:00
/* Native only */
src : PropTypes . object ,
2018-06-20 23:09:45 -06:00
seek : PropTypes . oneOfType ( [
PropTypes . number ,
2020-02-22 11:56:31 -07:00
PropTypes . object ,
2018-06-20 23:09:45 -06:00
] ) ,
2016-03-31 12:36:39 -06:00
fullscreen : PropTypes . bool ,
2016-12-12 17:16:11 -07:00
onVideoLoadStart : PropTypes . func ,
onVideoLoad : PropTypes . func ,
2017-01-11 05:51:45 -07:00
onVideoBuffer : PropTypes . func ,
2016-12-12 17:16:11 -07:00
onVideoError : PropTypes . func ,
onVideoProgress : PropTypes . func ,
2018-11-01 10:11:57 -06:00
onVideoBandwidthUpdate : PropTypes . func ,
2016-12-12 17:16:11 -07:00
onVideoSeek : PropTypes . func ,
onVideoEnd : PropTypes . func ,
2017-02-13 19:38:02 -07:00
onTimedMetadata : PropTypes . func ,
2018-07-12 22:48:58 -06:00
onVideoAudioBecomingNoisy : PropTypes . func ,
2018-10-07 16:59:10 -06:00
onVideoExternalPlaybackChange : PropTypes . func ,
2016-12-12 17:16:11 -07:00
onVideoFullscreenPlayerWillPresent : PropTypes . func ,
onVideoFullscreenPlayerDidPresent : PropTypes . func ,
onVideoFullscreenPlayerWillDismiss : PropTypes . func ,
onVideoFullscreenPlayerDidDismiss : PropTypes . func ,
2015-10-29 18:26:28 -06:00
/* Wrapper component */
2016-06-22 07:52:12 -06:00
source : PropTypes . oneOfType ( [
PropTypes . shape ( {
2020-02-22 11:56:31 -07:00
uri : PropTypes . string ,
2016-06-22 07:52:12 -06:00
} ) ,
// Opaque type returned by require('./video.mp4')
2020-02-22 11:56:31 -07:00
PropTypes . number ,
2016-06-22 07:52:12 -06:00
] ) ,
2019-02-10 20:21:02 -07:00
minLoadRetryCount : PropTypes . number ,
2018-11-26 15:50:31 -07:00
maxBitRate : PropTypes . number ,
2015-10-29 18:26:28 -06:00
resizeMode : PropTypes . string ,
2016-12-05 14:57:35 -07:00
poster : PropTypes . string ,
2017-04-30 05:43:01 -06:00
posterResizeMode : Image . propTypes . resizeMode ,
2015-10-29 18:26:28 -06:00
repeat : PropTypes . bool ,
2019-08-22 02:10:39 -06:00
automaticallyWaitsToMinimizeStalling : PropTypes . bool ,
2018-06-05 20:22:19 -06:00
allowsExternalPlayback : PropTypes . bool ,
2018-07-17 15:14:21 -06:00
selectedAudioTrack : PropTypes . shape ( {
type : PropTypes . string . isRequired ,
value : PropTypes . oneOfType ( [
PropTypes . string ,
2020-02-22 11:56:31 -07:00
PropTypes . number ,
] ) ,
2018-07-17 15:14:21 -06:00
} ) ,
2018-08-24 04:03:46 -06:00
selectedVideoTrack : PropTypes . shape ( {
type : PropTypes . string . isRequired ,
value : PropTypes . oneOfType ( [
PropTypes . string ,
2020-02-22 11:56:31 -07:00
PropTypes . number ,
] ) ,
2020-01-28 15:21:21 -07:00
} ) ,
2018-06-02 03:24:13 -06:00
selectedTextTrack : PropTypes . shape ( {
type : PropTypes . string . isRequired ,
value : PropTypes . oneOfType ( [
PropTypes . string ,
2020-02-22 11:56:31 -07:00
PropTypes . number ,
] ) ,
2018-06-02 03:24:13 -06:00
} ) ,
2018-06-12 22:04:15 -06:00
textTracks : PropTypes . arrayOf (
PropTypes . shape ( {
title : PropTypes . string ,
uri : PropTypes . string . isRequired ,
type : PropTypes . oneOf ( [
TextTrackType . SRT ,
TextTrackType . TTML ,
TextTrackType . VTT ,
] ) ,
2020-02-22 11:56:31 -07:00
language : PropTypes . string . isRequired ,
2018-06-12 22:04:15 -06:00
} )
) ,
2015-10-29 18:26:28 -06:00
paused : PropTypes . bool ,
muted : PropTypes . bool ,
volume : PropTypes . number ,
2018-08-02 01:20:08 -06:00
bufferConfig : PropTypes . shape ( {
2018-08-01 07:58:02 -06:00
minBufferMs : PropTypes . number ,
maxBufferMs : PropTypes . number ,
bufferForPlaybackMs : PropTypes . number ,
bufferForPlaybackAfterRebufferMs : PropTypes . number ,
} ) ,
2018-06-05 16:04:20 -06:00
stereoPan : PropTypes . number ,
2015-10-29 18:26:28 -06:00
rate : PropTypes . number ,
2018-11-26 15:23:04 -07:00
pictureInPicture : PropTypes . bool ,
2015-12-16 05:53:04 -07:00
playInBackground : PropTypes . bool ,
2020-05-15 01:25:19 -06:00
preferredForwardBufferDuration : PropTypes . number ,
2016-04-29 05:55:34 -06:00
playWhenInactive : PropTypes . bool ,
2017-04-20 12:10:06 -06:00
ignoreSilentSwitch : PropTypes . oneOf ( [ 'ignore' , 'obey' ] ) ,
2018-08-25 10:23:11 -06:00
reportBandwidth : PropTypes . bool ,
2017-01-11 05:51:45 -07:00
disableFocus : PropTypes . bool ,
2015-12-22 16:39:04 -07:00
controls : PropTypes . bool ,
2018-06-20 17:52:48 -06:00
audioOnly : PropTypes . bool ,
2015-12-22 16:39:04 -07:00
currentTime : PropTypes . number ,
2018-10-18 16:21:46 -06:00
fullscreenAutorotate : PropTypes . bool ,
2020-01-28 15:21:21 -07:00
fullscreenOrientation : PropTypes . oneOf ( [ 'all' , 'landscape' , 'portrait' ] ) ,
2016-10-01 12:23:50 -06:00
progressUpdateInterval : PropTypes . number ,
2018-06-08 01:01:13 -06:00
useTextureView : PropTypes . bool ,
2018-11-28 05:56:58 -07:00
hideShutterView : PropTypes . bool ,
2015-10-29 18:26:28 -06:00
onLoadStart : PropTypes . func ,
onLoad : PropTypes . func ,
2017-01-11 05:51:45 -07:00
onBuffer : PropTypes . func ,
2015-10-29 18:26:28 -06:00
onError : PropTypes . func ,
onProgress : PropTypes . func ,
2018-11-01 10:11:57 -06:00
onBandwidthUpdate : PropTypes . func ,
2015-11-11 14:34:41 -07:00
onSeek : PropTypes . func ,
2015-10-29 18:26:28 -06:00
onEnd : PropTypes . func ,
2016-03-31 13:35:10 -06:00
onFullscreenPlayerWillPresent : PropTypes . func ,
onFullscreenPlayerDidPresent : PropTypes . func ,
onFullscreenPlayerWillDismiss : PropTypes . func ,
onFullscreenPlayerDidDismiss : PropTypes . func ,
2016-04-28 06:42:44 -06:00
onReadyForDisplay : PropTypes . func ,
onPlaybackStalled : PropTypes . func ,
onPlaybackResume : PropTypes . func ,
onPlaybackRateChange : PropTypes . func ,
2017-01-11 05:51:45 -07:00
onAudioFocusChanged : PropTypes . func ,
onAudioBecomingNoisy : PropTypes . func ,
2018-11-26 15:23:04 -07:00
onPictureInPictureStatusChanged : PropTypes . func ,
needsToRestoreUserInterfaceForPictureInPictureStop : PropTypes . func ,
2018-09-13 06:06:12 -06:00
onExternalPlaybackChange : PropTypes . func ,
2015-10-29 18:26:28 -06:00
/* Required by react-native */
2016-06-22 07:52:12 -06:00
scaleX : PropTypes . number ,
scaleY : PropTypes . number ,
translateX : PropTypes . number ,
translateY : PropTypes . number ,
rotation : PropTypes . number ,
2017-11-03 12:38:37 -06:00
... ViewPropTypes ,
2015-10-29 18:26:28 -06:00
} ;
2015-11-03 21:27:38 -07:00
const RCTVideo = requireNativeComponent ( 'RCTVideo' , Video , {
2015-10-29 18:26:28 -06:00
nativeOnly : {
src : true ,
seek : true ,
2016-04-01 03:12:50 -06:00
fullscreen : true ,
2015-10-29 18:26:28 -06:00
} ,
} ) ;