react-native-video-fullscreen
A <Video>
component for react-native, based on react-native-video
Requires react-native >= 0.41.0
Add it to your project
Run npm install react-native-video-fullscreen
or yarn add react-native-video-fullscreen
Linking
Automatical
Run react-native link
Manual
iOS
Run react-native link
to link the react-native-video library.
If you would like to allow other apps to play music over your video component, add:
AppDelegate.m
#import <AVFoundation/AVFoundation.h> // import
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; // allow
...
}
Android
Run react-native link
to link the react-native-video library.
Or if you have trouble, make the following additions to the given files manually:
android/settings.gradle
include ':react-native-video-fullscreen'
project(':react-native-video-fullscreen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video-fullscreen/android')
android/app/build.gradle
dependencies {
...
compile project(':react-native-video-fullscreen')
}
MainApplication.java
On top, where imports are:
import com.brentvatne.react.ReactVideoPackage;
Under .addPackage(new MainReactPackage())
:
.addPackage(new ReactVideoPackage())
Usage
<Video source={{uri: "background"}}
ref={(ref) => {
this.player = ref
}}
rate={1.0}
volume={1.0}
muted={false}
paused={false}
resizeMode="cover"
repeat={true}
playInBackground={false}
playWhenInactive={false}
progressUpdateInterval={250.0}
onLoadStart={this.loadStart}
onLoad={this.setDuration}
onProgress={this.setTime}
onEnd={this.onEnd}
onError={this.videoError}
onBuffer={this.onBuffer}
style={styles.backgroundVideo} />
this.player.presentFullscreenPlayer()
this.player.seek(0)
var styles = StyleSheet.create({
backgroundVideo: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
},
});
Android Expansion File Usage
<Video source={{uri: "background", mainVer: 1, patchVer: 0}}
rate={1.0}
volume={1.0}
muted={false}
paused={false}
resizeMode="cover"
repeat={true}
onLoadStart={this.loadStart}
onLoad={this.setDuration}
onProgress={this.setTime}
onEnd={this.onEnd}
onError={this.videoError}
style={styles.backgroundVideo} />
var styles = Stylesheet.create({
backgroundVideo: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
},
});
MIT Licensed