
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@chaimpan/react-native-jwplayer
Advanced tools
React-native Android/iOS plugin for JWPlayer SDK (https://www.jwplayer.com/)
npm install https://github.com/chaimPaneth/react-native-jwplayer.git --save
or $ yarn add https://github.com/chaimPaneth/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', '~> 3.5.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.
Insert the following lines inside the dependencies block in android/app/build.gradle
:
implementation 'com.longtailvideo.jwplayer:jwplayer-core:+'
implementation 'com.longtailvideo.jwplayer:jwplayer-common:+'
Add to AndroidManifest.xml in the Application tag above the Activity tag:
<meta-data
android:name="JW_LICENSE_KEY"
android:value="<API_KEY_FOUND_IN_JW_DASHBOARD>" />
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-jwplayer
and add RNJWPlayer.xcodeproj
libRNJWPlayer.a
to your project's Build Phases
➜ Link Binary With Libraries
Cmd+R
)<android/app/src/main/java/[...]/MainApplication.java
import net.gamesofton.rnjwplayer.RNJWPlayerPackage;
to the imports at the top of the filenew RNJWPlayerPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-jwplayer'
project(':react-native-jwplayer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-jwplayer/android')
android/app/build.gradle
:
implementation project(':react-native-jwplayer')
...
import JWPlayer from 'react-native-jwplayer';
...
const styles = StyleSheet.create({
container: {
flex: 1,
},
player: {
flex: 1,
},
});
...
componentDidMount() {
const playlistItem = {
title: 'Track',
mediaId: -1,
image: 'http://image.com/image.png',
desc: 'My beautiful track',
time: 0,
file: 'http://file.com/file.mp3',
autostart: true,
controls: true,
repeat: false,
displayDescription: true,
displayTitle: true
}
this.JWPlayer.loadPlaylistItem(playlistItem);
// for playlist
// const playlist = [playlistItem, playlistItem]
// this.JWPlayer.loadPlaylist(playlistItem);
}
...
render() {
...
<View style={styles.container}>
<JWPlayer
ref={p => (this.JWPlayer = p)}
style={styles.player}
onBeforePlay={() => this.onBeforePlay()}
onPlay={() => this.onPlay()}
onPause={() => this.onPause()}
onIdle={() => console.log("onIdle")}
onPlaylistItem={event => this.onPlaylistItem(event)}
onSetupPlayerError={event => this.onPlayerError(event)}
onPlayerError={event => this.onPlayerError(event)}
onBuffer={() => this.onBuffer()}
onTime={event => this.onTime(event)}
onFullScreen={() => this.onFullScreen()}
onFullScreenExit={() => this.onFullScreenExit()}
/>
</View>
...
}
For running example project:
Example
directory and run yarn
or npm i
Example/ios
and install Pods with pod install
demoJWPlayer.xcworkspace
with XCode.Info.plist
Prop | Description | Type |
---|---|---|
mediaId | The JW media id. | Int |
file | The url of the file to play. | String |
title | The title of the track. | String |
image | The url of the player thumbnail. | String |
autostart | Should the track auto start. | Boolean |
time | should the player seek to a certain second. | Int |
desc | Description of the track. | String |
controls | Should the control buttons show. | Boolean |
repeat | Should the track repeat. | Boolean |
displayDescription | Should the player show the description. | Boolean |
displayTitle | Should the player show the title. | Boolean |
Prop | Description | Type |
---|---|---|
mediaId | The JW media id. | Int |
file | The url of the file to play. | String |
title | The title of the track. | String |
image | The url of the player thumbnail. | String |
autostart | Should the track auto start. | Boolean |
time | should the player seek to a certain second. | Int |
desc | Description of the track. | String |
controls | Should the control buttons show. | Boolean |
repeat | Should the track repeat. | Boolean |
displayDescription | Should the player show the description. | Boolean |
displayTitle | Should the player show the title. | Boolean |
playlistItem | An object of playlistItem shape. | PlaylistItem |
playlist | An array of playlistItems. | [playlistItem] see PlaylistItem] |
nextUpDisplay | Should the player show the next up item in a playlist. | Boolean |
playerStyle | Name of css file you put in the Main Bundle for you custom style. See below Custom-style section. | String |
Func | Description | Argument |
---|---|---|
seekTo | Tells the player to seek to position, use in onPlaylistItem callback so player finishes buffering file. | Int |
play | Starts playing. | none |
pause | Pauses playing. | none |
stop | Stops the player completely. | none |
state | Returns the current state of the player idle , buffering , playing , paused . | none |
position | Returns the current position of the player in seconds. | none |
toggleSpeed | Toggles the player speed one of 0.5 , 1.0 , 1.5 , 2.0 . | none |
setPlaylistIndex | Sets the current playing item in the loaded playlist. | Int |
setControls | Sets the display of the control buttons on the player. | Boolean |
loadPlaylist | Loads a playlist. | [PlaylistItems] |
loadPlaylistItem | Loads a playlist item. | PlaylistItem |
Func | Description | Argument |
---|---|---|
onPlaylist | A new playlist is loaded. | [playlistItem] see PlaylistItem |
onBeforePlay | Right before playing. | none |
onBeforeComplete | Right before playing completed and is starting to play. | none |
onPlay | Player started playing. | none |
onPause | Player paused playing. | none |
onSetupPlayerError | Player faced and error while setting up the player. | {error: String} |
onPlayerError | Player faced an error after setting up the player but when attempting to start playing. | {error: String} |
onBuffer | The player is buffering. | none |
onTime | Interval callback for every millisecond playing. | {time: double, duration: double} |
onFullScreen | User clicked on the fullscreen icon. Use this to resize the container view for the player. (Make use of https://github.com/yamill/react-native-orientation for fullscreen mode) | none |
onFullScreenExit | User clicked on the fullscreen icon to exit. | none |
onPlaylistItem | When starting to play a playlist item. | JW type playlist item see docs ios, android contains additional index of current playing item in playlist 0 for default |
For setting a custom style on the player:
Check out the JW player guide for adding a custom css file on your player.
Put your custom css file in the root folder of your native files.
Add the prop playerStyle
to the player and set to the name of your css file without the .css file type e.g. playerStyle={'myCssFile'}
.
build & run.
FAQs
React-native Android/iOS plugin for JWPlayer SDK (https://www.jwplayer.com/)
The npm package @chaimpan/react-native-jwplayer receives a total of 0 weekly downloads. As such, @chaimpan/react-native-jwplayer popularity was classified as not popular.
We found that @chaimpan/react-native-jwplayer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.