React Native Android Video
react-native-android-video
Android ExoPlayer
<Video />
component for react-native.
Installation
Using npm:
$ npm install --save react-native-android-video
Or using yarn:
$ yarn add react-native-android-video
Android
- Append the following lines to
android/settings.gradle
:
include ':react-native-android-video'project(':react-native-android-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-video/src/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:
compile project(':react-native-android-video')
- Open
MainApplication.java
:
- Import the package on top of the file:
- Add the
RNAndroidVideoPackage
class to your list of exported packages:
@Overrideprotected List<ReactPackage> { return Arrays.<ReactPackage>;}
Usage
// Import the module ... // In your render function<AndroidVideo ref= { thisplayer = ref } style=stylesvideo source=thispropsvideoUrl paused=!thispropsisPlaying rate=thispropsplayerRate onPlayerReady=this_onVideoReady onPlayerLoading=this_onVideoPlayerLoading onProgress=this_onVideoPlayerProgress onPlayerError=this_onVideoError/>
Configurable props
Property | Type | Description |
---|---|---|
source | string | Sets the media source |
paused | boolean | Controls whether the media is paused |
rate | number | Speed at which the media should play |
Event props
onPlayerReady
Callback function that is called when the media is loaded and the player is ready to play.
Payload:
Property | Type | Description |
---|---|---|
duration | number | The duration of the media in milliseconds |
onPlayerLoading
Callback function that is called when the player is start or stop buffering.
Payload: true / false
.
onProgress
Callback function that is called every 250 mili seconds with info about which position the media is currently playing.
Payload:
Property | Type | Description |
---|---|---|
currentTime | number | Current player position in seconds |
onPlayerError
Callback function that is called when error is occurs.
Payload:
Property | Type | Description |
---|---|---|
error | string | Error message |
Methods
seek
Seek to the specified position represented by seconds.
Example:
thisplayer
Authors
- Alon Shprung - Initial code
See also the list of contributors who participated in this project.
Contributing
Pull requests are welcome.