2017-08-04 12:53:53 -06:00
|
|
|
import React, {Component} from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-10-26 07:21:41 -06:00
|
|
|
import {StyleSheet, requireNativeComponent, NativeModules, View, ViewPropTypes, Image, Platform, findNodeHandle} 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 = {
|
|
|
|
showPoster: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-11-09 18:55:39 -07:00
|
|
|
setNativeProps(nativeProps) {
|
|
|
|
this._root.setNativeProps(nativeProps);
|
|
|
|
}
|
2018-01-13 13:28:24 -07:00
|
|
|
|
|
|
|
toTypeString(x) {
|
|
|
|
switch (typeof x) {
|
|
|
|
case "object":
|
|
|
|
return x instanceof Date
|
|
|
|
? x.toISOString()
|
|
|
|
: JSON.stringify(x); // object, null
|
|
|
|
case "undefined":
|
|
|
|
return "";
|
|
|
|
default: // boolean, number, string
|
|
|
|
return x.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) => {
|
2018-10-12 09:59:36 -06:00
|
|
|
if (isNaN(time)) throw new Error('Specified time is not a number');
|
|
|
|
|
2018-06-20 23:09:45 -06:00
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
this.setNativeProps({
|
|
|
|
seek: {
|
|
|
|
time,
|
|
|
|
tolerance
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} 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));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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) => {
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-22 08:28:54 -06:00
|
|
|
_onSeek = (event) => {
|
2018-05-29 13:59:21 -06:00
|
|
|
if (this.state.showPoster && !this.props.audioOnly) {
|
2016-12-05 14:57:35 -07:00
|
|
|
this.setState({showPoster: false});
|
|
|
|
}
|
|
|
|
|
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) => {
|
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) => {
|
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) => {
|
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) => {
|
2018-06-20 17:52:48 -06:00
|
|
|
if (this.state.showPoster && event.nativeEvent.playbackRate !== 0 && !this.props.audioOnly) {
|
2016-12-08 07:12:34 -07:00
|
|
|
this.setState({showPoster: false});
|
|
|
|
}
|
|
|
|
|
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
|
|
|
};
|
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();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
_onAudioFocusChanged = (event) => {
|
|
|
|
if (this.props.onAudioFocusChanged) {
|
|
|
|
this.props.onAudioFocusChanged(event.nativeEvent);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
_onBuffer = (event) => {
|
|
|
|
if (this.props.onBuffer) {
|
|
|
|
this.props.onBuffer(event.nativeEvent);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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) || {};
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
if (resizeMode === VideoResizeMode.stretch) {
|
2015-11-05 18:13:35 -07:00
|
|
|
nativeResizeMode = NativeModules.UIManager.RCTVideo.Constants.ScaleToFill;
|
2015-10-29 18:26:28 -06:00
|
|
|
} else if (resizeMode === VideoResizeMode.contain) {
|
2015-11-05 18:13:35 -07:00
|
|
|
nativeResizeMode = NativeModules.UIManager.RCTVideo.Constants.ScaleAspectFit;
|
2015-10-29 18:26:28 -06:00
|
|
|
} else if (resizeMode === VideoResizeMode.cover) {
|
2015-11-05 18:13:35 -07:00
|
|
|
nativeResizeMode = NativeModules.UIManager.RCTVideo.Constants.ScaleAspectFill;
|
2015-10-29 18:26:28 -06:00
|
|
|
} else {
|
2015-11-05 18:13:35 -07:00
|
|
|
nativeResizeMode = NativeModules.UIManager.RCTVideo.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,
|
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,
|
2017-10-02 12:11:41 -06: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,
|
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
|
|
|
|
2015-11-09 18:55:39 -07:00
|
|
|
return (
|
2018-08-04 15:28:33 -06:00
|
|
|
<React.Fragment>
|
|
|
|
<RCTVideo ref={this._assignRoot} {...nativeProps} />
|
|
|
|
{this.props.poster &&
|
|
|
|
this.state.showPoster && (
|
|
|
|
<View style={nativeProps.style}>
|
|
|
|
<Image style={posterStyle} source={{ uri: this.props.poster }} />
|
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
</React.Fragment>
|
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([
|
|
|
|
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,
|
|
|
|
FilterType.SEPIA
|
|
|
|
]),
|
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,
|
|
|
|
PropTypes.object
|
|
|
|
]),
|
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({
|
|
|
|
uri: PropTypes.string
|
|
|
|
}),
|
|
|
|
// Opaque type returned by require('./video.mp4')
|
|
|
|
PropTypes.number
|
|
|
|
]),
|
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,
|
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,
|
|
|
|
PropTypes.number
|
|
|
|
])
|
|
|
|
}),
|
2018-08-24 04:03:46 -06:00
|
|
|
selectedVideoTrack: PropTypes.shape({
|
|
|
|
type: PropTypes.string.isRequired,
|
|
|
|
value: PropTypes.oneOfType([
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.number
|
|
|
|
])
|
|
|
|
}),
|
2018-06-02 03:24:13 -06:00
|
|
|
selectedTextTrack: PropTypes.shape({
|
|
|
|
type: PropTypes.string.isRequired,
|
|
|
|
value: PropTypes.oneOfType([
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.number
|
|
|
|
])
|
|
|
|
}),
|
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,
|
|
|
|
]),
|
|
|
|
language: PropTypes.string.isRequired
|
|
|
|
})
|
|
|
|
),
|
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,
|
2015-12-16 05:53:04 -07:00
|
|
|
playInBackground: PropTypes.bool,
|
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,
|
2018-10-09 17:01:41 -06: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-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
|
|
|
},
|
|
|
|
});
|