$ npm install react-native-jwplayer --save
or $ yarn add react-native-jwplayer
(is not supported until not published in npm)
Current working case (whili isn't in npm) is
$ yarn add https://github.com/nulleof/react-native-jwplayer.git
Link module with
$ react-native link react-native-jwplayer
Then add SDK dependencies:
Follow official instruction sdk ios installation for installation via Cocoapods (only supported, other way wasn't tested).
Add pod 'JWPlayer-SDK', '~> 2.0'
to your Podfile.
Then run pod install from your ios
directory.
In your info.plist
properties file, create an string entry named JWPlayerKey
, and set its value to be your JW Player Beta license key. Make sure you enter this string exactly as you received it from JW Player, or as it appears in your JW Player Dashboard. The string is case-sensitive.
Coming soon.
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-jwplayer
and addRNJWPlayer.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNJWPlayer.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Add dependencies
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import net.gamesofton.rnjwplayer.RNJWPlayerPackage;
to the imports at the top of the file - Add
new RNJWPlayerPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-jwplayer' project(':react-native-jwplayer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-jwplayer/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-jwplayer')
- Add dependencies
...
import JWPlayer from 'react-native-jwplayer';
...
const styles = StyleSheet.create({
container: {
flex: 1,
},
player: {
flex: 1,
},
});
...
render() {
...
<View style={styles.container}>
<JWPlayer
style={styles.player}
autostart={false}
file={'https://content.jwplatform.com/manifests/vM7nH0Kl.m3u8'}
onBeforePlay={() => this.onBeforePlay()}
onPlay={() => this.onPlay()}
onPlayerError={e => this.onPlayerError(e)}
onBuffer={() => this.onBuffer()}
onTime={time => this.onTime(time)}
/>
</View>
...
}
For running example project:
- Checkout this repository.
- Go to
Example
directory and runyarn
ornpm i
- Go to
Example/ios
and install Pods withpod install
- Open
demoJWPlayer.xcworkspace
with XCode. - Add your iOS api key for JWplayer into
Info.plist