Controls for the React Native
<Video> component at react-native-video. For support with RN 0.45 or lower use version 1.3.1 or lower.
This package contains a simple set of GUI controls that work with the react-native-video
<Video> component. This includes a back button, volume bar, fullscreen toggle, play/pause toggle, seekbar, title, error handling and timer toggle that can switch between time remaining and current time when tapped.
By default the
<VideoPlayer> accepts a navigator property from React's built-in
<Navigator> which pops the current scene off the stack when tapped. Alternatively you can provide your own onBack prop to the component to override this functionality. You should also provide your own onEnd prop to the component so it knows what to do when a video ends playback.
By default, tapping the screen anywhere will show the player controls. After 10s the controls disappear. Double tapping will toggle fullscreen.
npm install --save react-native-video react-native-video-controls
react-native link react-native-video
If you're using RN < 39 run
npm install --save firstname.lastname@example.org. Note this version includes
react-native-video as a normal dependency instead of a peer-dependency.
For basic operation the
<VideoPlayer> component requires a video source and a navigator property. The default back button functionality in the component relies on using the built-in
<Navigator> functionality in React Native and pops the current scene off the stack. This can be overridden if desired, see the API for more details.
// At the top where our imports are...;// in the component's render() function<VideoPlayersource= uri: ''navigator= thispropsnavigator/>
To play a local file, use require syntax like so:
<VideoPlayer source= />
<VideoPlayer> component can take a number of inputs to customize it as needed. They are outlined below:
You can pass any of the props that the
<Video /> component at react-native-video takes. Simply add them onto the
<VideoPlayer /> and it will pass them through to the
<Video /> component.
In addition, the
<VideoPlayer /> also takes these props:
|toggleResizeModeOnFullscreen||Boolean||true||If true, clicking the fullscreen button will toggle the
|controlTimeout||Integer||15000||Hide controls after X amount of time in milliseconds|
|showOnStart||Boolean||true||Show or hide the controls on first render|
|videoStyle||StyleSheet||null||React Native StyleSheet object that is appended to the
|navigator||Navigator||null||When using the default React Native navigator and do not override the
|seekColor||String(#HEX)||'#FFF'||Fill/handle colour of the seekbar|
|style||StyleSheet||null||React Native StyleSheet object that is appended to the video's parent
These are various events that you can hook into and fire functions on in the component:
|onEnterFullscreen||Fired when the video enters fullscreen after the fullscreen button is pressed|
|onExitFullscreen||Fired when the video exits fullscreen after the fullscreen button is pressed|
|onError||Fired when an error is encountered when loading the video|
|onPause||Fired when the video is paused after the play/pause button is pressed|
|onPlay||Fired when the video begins playing after the play/pause button is pressed|
|onBack||Function fired when back button is pressed, override if using custom navigation|
|onEnd||Fired when the video is complete|
These are the various controls that you can turn on/off as needed. All of these props default to false, override them to disable any controls
|disableFullscreen||Hide the fullscreen button|
|disablePlayPause||Hide the play/pause toggle|
|disableSeekbar||Hide the seekbar|
|disableVolume||Hide the Volume control|
|disableTimer||Hide the timer|
|disableBack||Hide the back button|