Coder Social home page Coder Social logo

react-jw-player's Introduction

react-jw-player 🎥 Build Status

<ReactJWPlayer> is a React Component for initializing client-side instances of JW Player. Simply give <ReactJWPlayer> the id of your player script, and the id of a JW Player video or playlist. The component comes with several event hooks that can be accessed through component props.

Contents

Installation

npm install react-jw-player

Usage

At the mininum, you can just use something like the three following code snippets:

Playing a JW Player JSON Playlist

import React from 'react';
import ReactDOM from 'react-dom';
import ReactJWPlayer from 'react-jw-player';

ReactDOM.render(
  <ReactJWPlayer
    playerId='my-unique-id'
    playerScript='https://link-to-my-jw-player/script.js'
    playlist='https://link-to-my-playlist.json'
  />,
  document.getElementById('my-root-div');
);

Playing a custom Playlist

import React from 'react';
import ReactDOM from 'react-dom';
import ReactJWPlayer from 'react-jw-player';

const playlist = [{
  file: 'https://link-to-my-video.mp4',
  image: 'https://link-to-my-poster.jpg',
  tracks: [{
    file: 'https://link-to-subtitles.vtt',
    label: 'English',
    kind: 'captions',
    'default': true
  }],
},
{
  file: 'https://link-to-my-other-video.mp4',
  image: 'https://link-to-my-other-poster.jpg',
}];

ReactDOM.render(
  <ReactJWPlayer
    playerId='my-unique-id'
    playerScript='https://link-to-my-jw-player/script.js'
    playlist={playlist}
  />,
  document.getElementById('my-root-div');
);

Playing a Specific File

import React from 'react';
import ReactDOM from 'react-dom';
import ReactJWPlayer from 'react-jw-player';

ReactDOM.render(
  <ReactJWPlayer
    playerId='my-unique-id'
    playerScript='https://link-to-my-jw-player/script.js'
    file='https://link-to-my-video.mp4'
  />,
  document.getElementById('my-root-div');
);

For more complex interaction, check out the container component example here

To generate preroll, supply the player with the generatePrerollUrl prop. This prop just needs to be a function that returns a valid VAST tag! See Optional Configuration Props for more info.

Required Props

These are props that modify the basic behavior of the component.

  • playerId
    • A unique Id for the player instance. Used to distinguish the container divs.
    • Type: string
    • Example: playerId="my-jw-player-instance"
  • playerScript
    • Link to a valid JW Player script.
    • Type: string
    • Example: https://content.jwplatform.com/libraries/abCD1234.js
  • playlist OR file
    • Link to a valid JW Player playlist or video file, or playlist array. Cool tip: JW Player automatically generates JSON feeds for individual videos if you use the video id in place of abCD1234. You can use this to get meta data on the videos without loading an actual playlist.
    • Type: string (for file and playlist) or array (for playlist)
    • Example: https//content.jwplatform.com/feeds/abCD1234.json

Optional Configuration Props

  • aspectRatio
    • An optional aspect ratio to give the video player. Can be 'inherit', 1:1 or 16:9 currently.
    • Defaults to 'inherit'.
  • className
    • An optional class name to give the container div.
    • Type: string
  • customProps
    • An optional object containing properties to be applied directly to the JW Player instance. Add anything in the API, like skins, into this object. customProps={{ skin: { name: 'six' } }}.
    • Type: object
  • isAutoPlay
    • Determines whether the player starts automatically or not.
    • Type: boolean
  • isMuted
    • Determines whether the player starts muted or not.
    • Type: boolean
  • generatePrerollUrl(video)
    • Supply a function that returns a VAST or GOOGIMA tag for use in generating a preroll advertisement.
    • Arguments:
      • video
        • This is a video object for the current item loaded in the player. You can use it to help generate your preroll tags.
  • image
    • URL to a poster image to display before playback starts
    • Type: string
  • licenseKey
    • License Key as supplied in the jwplayer dashboard, under: Players > Tools > Downloads > JW Player X (Self-Hosted)
    • Type: string
  • useMultiplePlayerScripts
    • EXPERIMENTAL - Allows you to load multiple player scripts and still load the proper configuration. Expect bugs, but report them!
    • Type: boolean

Event Hooks

react-jw-player dynamically supports all events in JW Player. Simply preface the event name with on and pass it in as a prop.

Examples:

  • ready => onReady
  • setupError => onSetupError

react-jw-player has layered some different functionality on some of these events, so please check the docs below if you find any unexpected behavior!

Optional Advertising Event Hook Props

  • onAdPause(event)
    • A function that is run when the user pauses the preroll advertisement.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onAdPlay(event)
    • A function that is run once, when the preroll advertisement first starts to play.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onAdResume(event)
    • A function that is run when the user resumes playing the preroll advertisement.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onAdSkipped(event)
    • A function that is run when the user skips an advertisement.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onAdComplete(event)
    • A function that is run when an ad has finished playing.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.

Optional Player Event Hook Props

  • onAutoStart(event)
    • A function that is run once, when an autoplaying player starts to play a video.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onEnterFullScreen(event)
    • A function that is run when the user fullscreens a video.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onError(event)
    • A function that is run when the player errors.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onExitFullScreen(event)
    • A function that is run when the user un-fullscreens a video.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onMute(event)
    • A function that is run when the user mutes the player.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onPause(event)
    • A function that is run when the user pauses the player during a video.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onPlay(event)
    • A function that is run when a video first starts to play.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onReady(event)
    • A function that is run once when the video player is ready.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onResume(event)
    • A function that is run when the user plays a video after pausing it.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onSetupError(event)
    • A function that is run when the player errors during setup.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onTime(event)
    • A function that is run whenever the playback position gets updated.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onUnmute(event)
    • A function that is run when the user unmutes the player.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onVideoLoad(event)
    • A function that is run whenever a new video is loaded into the player.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.

Optional Time Event Hook Props

  • onThreeSeconds(event)
    • A function that is run when the playhead reaches passed the 3 second mark.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onTenSeconds(event)
    • A function that is run when the playhead reaches passed the 10 second mark.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onThirtySeconds(event)
    • A function that is run when the playhead reaches passed the 30 second mark.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onTwentyFivePercent(event)
    • A function that is run when the playhead reaches passed the 25% mark.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onFiftyPercent(event)
    • A function that is run when the playhead reaches passed the 50% mark.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onSeventyFivePercent(event)
    • A function that is run when the playhead reaches passed the 75% mark.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onNinetyFivePercent(event)
    • A function that is run when the playhead reaches passed the 95% mark.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.
  • onOneHundredPercent(event)
    • A function that is run when the a video ends.
    • Type: function
    • Arguments:
      • event
        • This is the event object passed back from JW Player itself.

Example Container Component

import React from 'react';
import PropTypes from 'prop-types';

import ReactJWPlayer from 'react-jw-player';

const displayName = 'ReactJWPlayerContainer';

const propTypes = {
  playlist: PropTypes.string.isRequired,
  playerScript: PropTypes.string.isRequired
};

class ReactJWPlayerContainer extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      videoTitle: '',
    };

    this.onAdPlay = this.onAdPlay.bind(this);
    this.onReady = this.onReady.bind(this);
    this.onVideoLoad = this.onVideoLoad.bind(this);

    // each instance of <ReactJWPlayer> needs a unique id.
    // we randomly generate it here and assign to the container instance.
    this.playerId = someFunctionToRandomlyGenerateId();
  }
  onReady(event) {
    // interact with JW Player API here
    const player = window.jwplayer(this.playerId);
  }
  onAdPlay(event) {
    // track the ad play here
  }
  onVideoLoad(event) {
    this.setState({
      videoTitle: event.item.description // this only works with json feeds!
    });
  }
  render() {
    return (
      <div className='react-jw-player-container'>
        <h1>{ this.state.videoTitle }</h1>
        <ReactJWPlayer
          playlist={this.props.playlist}
          licenseKey='your-license-key'
          onAdPlay={this.onAdPlay}
          onReady={this.onReady}
          onVideoLoad={this.onVideoLoad}
          playerId={this.playerId} // bring in the randomly generated playerId
          playerScript='https://link-to-your-jw-player-script.js'
        />
      </div>
    );
  }
}

ReactJWPlayerContainer.propTypes = propTypes;
ReactJWPlayerContainer.defaultProps = defaultProps;
ReactJWPlayerContainer.displayName = displayName;
export default ReactJWPlayerContainer;

Contributing

Just do it!

shia

react-jw-player's People

Contributors

alinchican avatar chrisdugne avatar danmakenoise avatar djcsdy avatar dtamburr avatar duongthienduc avatar dustingibbs avatar ellell avatar esetnik avatar francescocaveglia avatar justinoneill-abc avatar nirarazi avatar orrybaram avatar petertdinh avatar ryanscottaudio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-jw-player's Issues

FullScreen functionlity is not working.

Hi team.
My code is below.
const config = {
playerId: '1',
isAutoPlay: true,
className: 'jwp',
width: 160,
height: 90,
playlist: [
{
file: 'http://vjs.zencdn.net/v/oceans.mp4',
image: 'http://vjs.zencdn.net/v/oceans.png',
tracks: [
{
file: 'https://link-to-subtitles.vtt',
label: 'English',
kind: 'captions',
' default': true
}
]
},
{
file: 'http://vjs.zencdn.net/v/oceans.mp4',
image: 'http://vjs.zencdn.net/v/oceans.png'
}
],
playerScript:
'xxx/jwplayer.js',
licenseKey: 'kQB2==',
customProps: {
skin: { name: 'Small' }
}
};

class VideoPlayer extends React.Component {
constructor(props) {
super(props);
this.state = {
videoTitle: ''
};
this.player = '';
this.onAdPlay = this.onAdPlay.bind(this);
this.onReady = this.onReady.bind(this);
this.onVideoLoad = this.onVideoLoad.bind(this);
this.handleClick = this.handleClick.bind(this);
// each instance of needs a unique id.
// we randomly generate it here and assign to the container instance.
this.playerId = '1';
}
onReady(event) {
// interact with JW Player API here
this.player = window.jwplayer(config.playerId);
const playerContainer = this.player.getContainer();
const displayC = playerContainer.querySelector('.jw-display-controls');
console.log(displayC);
const rewindC = displayC.querySelector('.jw-display-icon-rewind');
const nextC = displayC.querySelector('.jw-display-icon-next');
console.log(rewindC);
const captionC = playerContainer.querySelector('.jw-icon-cc');
const fullscreen = playerContainer.querySelector('.jw-icon-fullscreen');
fullscreen.className += ' jw-display-icon-container';
captionC.className += ' jw-display-icon-container';
console.log(event);
console.log(this.player);
displayC.replaceChild(captionC, rewindC);
displayC.replaceChild(fullscreen, nextC);
}
onAdPlay(event) {
console.log(event);
}
onVideoLoad(event) {
this.setState({
videoTitle: event.item.description // this only works with json feeds!
});
}
handleClick = (e, eve) => {
console.log(e.target);
e.target.style.display = 'none';
const elem = document.getElementById(eve);
alert(elem);
elem.parentNode.removeChild(elem);
};

render() {
return (


{this.state.videoTitle}



<button
id="removebtn"
onClick={e => {
this.handleClick(e, this.playerId);
}}
>
Remove(x)


<ReactJWPlayer
{...config}
onAdPlay={this.onAdPlay}
onReady={this.onReady}
onVideoLoad={this.onVideoLoad}
/>

);
}
}

VideoPlayer.displayName = displayName;

export default VideoPlayer;

Background Image for podcast

Hi Team,
While playing podcast, I want to show a back ground image. Which property shall I use for it ?
I am using v1.16.0
Thanks

create preview in react jwplayer

hi my friends , i have to create a preview player before user upload video , so here i have base64 string file , when i put this string in file props , nothing shows , it is my code :

handleVideo(e) {
        e.preventDefault();
        let reader = new FileReader();
        let file = e.target.files[0];
        reader.onloadend = () => {
            this.setState({
                file: file,
                previewUrl: reader.result
            });
            const {previewUrl} = this.state;
            this.setState({preview:null});
            if (previewUrl) {
                this.setState({preview:(<ReactJWPlayer
                        className="player rtl"
                        playerId={"jwplayer"+Math.random().postId}
                        playerScript={Config.settings.jwplayer}
                        licenseKey={Config.settings.licenseKey}
                        file={previewUrl}
                    />)});
                console.log(previewUrl,this.state.preview);
            }
        };
        reader.readAsDataURL(file)
    }

my code works on normal video tag and shows the video correctly , but in jwplayer, it says " No playable source found "

Re-rendering [QUESTION]

Awesome package. Really works well with integration of React and JW. I do however need to change the video source of the player in my application quite a bit. Imagine a multiple-videos page. I want to re-render the VideoPlayer when I change the video on my Redux store. I have tried this.forceUpdate() and I've tried resetting/updating state but couldn't get it to work. Any ideas on how I'd go about doing this?

Is the better approach that I collect all of the videos and put them inside of a playlist and therefore wouldn't need to re-render the player?

Uncaught TypeError: n.setup is not a function - React 16

Ever since our upgrade to React 16 our app is throwing this error on our SPA app's page load. If we click into it from another page it loads correctly but refresh breaks the whole page. I've wrapped the jwplayer in react ErrorBoundary tags in order allow our pages to load but the underlying problem still exists.

The error is in this block of prettytified code.

"./node_modules/react-jw-player/dist/helpers/initialize.js": function(e, t, n) {
"use strict";
Object.defineProperty(t, "__esModule", {
value: !0
}),
t.default = function(e) {
var t = e.component
, n = e.player
, o = e.playerOpts;
n.setup(o), // Here
n.on("beforePlay", function(e) {
t.eventHandlers.onBeforePlay(e, n)
}),
n.on("ready", t.props.onReady),
n.on("setupError", t.eventHandlers.onError),
n.on("error", t.eventHandlers.onError),
n.on("adPlay", t.eventHandlers.onAdPlay),
n.on("adPause", t.props.onAdPause),
n.on("adSkipped", t.props.onAdSkipped),
n.on("adComplete", t.props.onAdComplete),
n.on("fullscreen", t.eventHandlers.onFullScreen),
n.on("pause", t.props.onPause),
n.on("play", t.eventHandlers.onPlay),
n.on("mute", t.eventHandlers.onMute),
n.on("playlistItem", t.eventHandlers.onVideoLoad),
n.on("time", t.eventHandlers.onTime),
n.on("beforeComplete", t.props.onOneHundredPercent),
n.on("buffer", t.props.onBuffer),
n.on("bufferChange", t.props.onBufferChange)
}
}

We're not doing anything different since the upgrade as far as I can tell. Another thing I should note is that we're an isomorphic app and it works in debug mode where everything is processed and rendered on the client but not in prod mode where everything is processed on the server and pushed to the client for rendering. I saw weird setup errors from this before but I think previous versions of react were more permissive.

My guess is something isn't checking if it's in a browser or not before firing setup but it's only a guess.

We're running
"react": "^16.0.0",
"react-jw-player": "^1.16.0",

and a hosted version of jwplayer-7.12.11

Any help or advice would be appreciated.

Version 2 Proposal

Hey gang!

We are about to get started building version 2 of this and I wanted to get some discussion going about a few things:

  1. A personal goal of mine is to decouple this component from JW Player's API much as possible. One way we've coupled the component pretty tightly is by making a lot of defaults in the configuration options. I think in version 2, it will be better to not override any defaults from player scripts and just let users add in their out config vis customProps. This will prevent us from having to add in a new component property for every single config option, over time.

  2. I also want to break out a base component from a wrapper component. My thought is that the base component ReactJWPlayerBase would ONLY map props to JW Player Event hooks. This component will be a great option for anyone looking to really customize the component. The second component could be just ReactJWPlayer, and we would move all of the "nice to have" functionality, like onFiftyPercent, having preroll automatically generated, etc.

This set up would allow us to decouple the base component from JW Player as much as possible, and allow us to have the container component more or less completely decoupled.

So here is what I would like some feedback on, including some other utility things.

  1. Should we break out ReactJWPlayer and ReactJWPlayerBase. How do we feel about those titles? How do we feel about the separation of logic between them.
  2. I'm considering changing up the linter from miclint to using eslint with an .eslintrc file directly. This should make contributing a little easier for those that have IDE's set up to automatically read and lint based upon .eslintrc
  3. I would like to add Flow typing to the component.
  4. I'm considering switching the testing library to Jest, after finding some pretty great productivity enhancements in my personal time. I don't have an issue with keeping tape if people feel strongly one way or the other.
  5. Since this will be a major version, is there anything else we should change?

onSeek

Does the react -jwp-player support the onSeek() functionality?

Package not working, getting "View config not found"

Hi,
After importing the package, like the following below code

import React, { Component } from 'react';
import ReactJWPlayer from 'react-jw-player';

export default class App extends Component {
  render() {
    return (
      <ReactJWPlayer
      playerId='playerKey'
      playerScript='playerJsFile'
      file='https://r3---sn-n4v7sn7y.googlevideo.com/videoplayback?requiressl=yes&mt=1517929632&expire=1517951352&ratebypass=yes&pl=17&sparams=dur%2Cei%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cexpire&ipbits=0&ei=GMV5WpOEBdSr-QOp2LOIDQ&ip=13.64.65.74&key=yt6&lmt=1517927989292326&itag=22&source=youtube&mv=m&fvip=3&ms=au%2Conr&signature=AFF6D142A23B438C22977B52CE82A5D434A7193E.BA4DE0AEE0DD118375B6F4C679EB8E3B8D17F671&mm=31%2C26&mn=sn-n4v7sn7y%2Csn-vgqsknes&id=o-ANreTWkCqXuec43UuIgOmLYGP8W8PqerEYwxsUE7UOhm&mime=video%2Fmp4&initcwndbps=25840000&dur=5002.065'
      />
    );
  }
}

using the following version in my application,

    "react": "16.2.0",
    "react-jw-player": "^1.16.0",
    "react-native": "0.52.1",

I am getting the following error in my emulator
screen shot 2018-02-06 at 8 45 07 pm

On first time load in a mobile device, Audio player is set to mute by default.

We are using JW Player as an audio player. We have some custom buttons for audio controles at the frontend but at the backend we are using JW Player to play the audio. We have an issue with the player in mobile devices. On first time loading the audio starts to play but is always muted by default. We have to manually unmute the player in order to listen to the sound. Same thing works well on web and the audio starts to play and is audible(is unmuted by default). But in mobile devices on first time load the player opens the songs in mute mode.

import React, { Component } from 'react';
import ReactJWPlayer from 'react-jw-player';

class Audio extends Component {

constructor(props) {
    super(props);
}

shouldComponentUpdate() {
	return false;
}

render() {
	return <ReactJWPlayer
			customProps={{width: 600, height: 40}}
            playerId="music-player"
            licenseKey='key'
            playerScript='scriptfile'
            file={this.props.active.file}
            onReady={this.props.onReady}
            isAutoPlay={true}
            image={this.props.active.image}
          />
}

}

export {Audio as JWPlayer}

exposing jwplayer object

I am using your module in my react app. and try to use jwplayer.on('time') or jwplayer().getPosition() but they are not available.
Is it possible to expose whole jwplayer object/event.

Cannot render additional players after rendering an initial set.

The way that the component initializes only works while the JW Player SDK is loading. Later attempts to render new players fail.

When the script already exists, the player tries to place its initialization function into the onload callback of that existing script tag. However, this does nothing since the scripts has already finished loading, previously. Instead, the component should also check for the existence of window.jwplayer as an indicator that the SDK is already loaded and functioning. Then it should initialize as normal.

Icon not rendering

Hi
thanks for your component
I used it and I have a problem with it
the player Icon does not show correctly
image

Specifying the file to play when a playlist is defined

Is specifying the video to play in a set playlist possible

  <ReactJWPlayer
    playerId='my-unique-id'
    playerScript='https://link-to-my-jw-player/script.js'
    playlist='https://link-to-my-playlist.json'
  />

And if not then is it possible to play a video hosted in jwplayer just from the video ID?

onPlaylistComplete event

I noticed that this library doesn't have an onPlaylistComplete event that is present in the jwplayer API documentation. Are you open to a pull request adding it, or do you have a specific reason for omitting it?

I also noticed you're missing "seek", but I suppose I can just use onPause and onPlay for that, most likely.

Support 'vast' ads

Looks like the advertisement settings under the implementation are hard-coded to support only google, yet docs say we can use callback to provide a VAST tag (url).

We need the client to be 'vast' for that to work.

Not resizing for responsive devices

Hello,
I am having trouble when using react-jw-player as my player is not resizing for mobile devices. It is maintaining a fixed width and height. I am attaching a screenshot from my jw dashboard to show the player version I am using (8.1.8) and that it is configured to be responsive. The player resizes fine outside of react when simply using the embed code from the jw dashboard.
Here is the code I am using. As you can see, I am just creating a basic component to play a specific file. (license key has been omitted). The video plays fine except for not resizing. Is there anything additional that needs to be done to have the player auto resize? Thank you!

import React from "react";
import ReactJWPlayer from 'react-jw-player';

const key = 'abc123';
const JWPlayer = props => (
 	  <div>
           <ReactJWPlayer
              className="jw-player"
              licenseKey={key}
              playerId='Test1'
              playerScript='https://content.jwplatform.com/players/EnaV52f7-gVbyfBkc.js"'
              file='https://content.jwplatform.com/manifests/EnaV52f7.m3u8'
             />
    </div>
);
export default JWPlayer;

jwplayer

Pass an object to the playlist prop

The playlist prop requires a valid link to a playlist json file. Would it be possible to pass a playlist object instead of a link string? I have self-hosted video files and I need to use a playlist to add captions (.vtt files).

Or would a captions or tracks prop be an option?

From JWPlayer doc:

var playerInstance = jwplayer("myElement")
playerInstance.setup({
    playlist: [{
        file: "/assets/sintel.mp4",
        image: "/assets/sintel.jpg",
        tracks: [{ 
            file: "/assets/captions-en.vtt", 
            label: "English",
            kind: "captions",
            "default": true 
        },{ 
            file: "/assets/captions-fr.vtt", 
            kind: "captions",
            label: "French"
        }]
    }]
});

DRM

can we use DRM on your library?

Set Appearance: streching

Hey

According to docs default streching should be uniform but what I see in my inspector elements tab is <video class="jw-video jw-reset" src="blob:http://localhost:3000/blabla" jw-loaded="data" style="object-fit: fill;"></video>. I found nothing about setting the object-fit in the code I'm working on and neither found any apperance in the react-jw-player node module.

Should I call jwplayer("myElement").setup() and set streching or is there a way to do it in for e. g. <ReactJWPlayer customProps={{}} />

Thanks!

Please rename `prop-types.js` to something else

Webpack has a bug (that I'm trying to get tracked down) where the resolution graph gets messed up and results in prop-types trying to require itself.

React's prop-types is moduleId 48 and react-jw-player's prop-types is moduleId 527. Instead of

var _propTypes = __webpack_require__(48);

I'm getting

var _propTypes = __webpack_require__(527);

Here's the snippet:

/***/ }),
/* 527 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _propTypes = __webpack_require__(527);

var _propTypes2 = _interopRequireDefault(_propTypes);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {
  aspectRatio: _propTypes2.default.oneOf(['inherit', '1:1', '16:9']),
  className: _propTypes2.default.string,
<snip rest>

While I realize this isn't technically your issue, it would help resolve what I'm seeing. Otherwise I'm going to have to fork until the webpack bug is found and fixed. 😞

Video won't play on Iphone

Some of my videos cannot be played on Iphone. It show's File could not be played. But it works fine on laptop. Anyone know how to solve it?

Setting HD toogle

Hi, I want to ask about how to set the video quality in react jwplayer. In my player, it shows the hd button but didn’t show the quality options. Can you tellme how to add the quality options?

onExitFullScreen firing as soon as onEnterFullScreen has fired

Hi guys,

When I click the players' full-screen button, it appears to flash up and then exit full screen again. After a little investigation, it appears that the onExitFullScreen event is being thrown as soon as it enters full screen.

Double clicking the video toggles full screen without an issue. So I suspect there's something up with the button.

Any help with this would be much appreciated!

Here's my current implementation:

import * as React from 'react';
import * as propTypes from 'prop-types';
import ReactJWPlayer from 'react-jw-player';
import LoaderComponent from '../../../shared/loader/loader.component';
import AlertComponent from '../../../shared/alert/alert';

class VideoBlockComponent extends React.Component<any, any> {

    constructor(props: any) {
        super(props)

        this.playerUrl = `url(/client/vendor/jw-player/jwplayer.js)`;
        this.defaultWidth = '100%';
        this.defaultAspectRatio = '16:9';

        this.onEnterFullScreen = this.onEnterFullScreen.bind(this);
        this.onExitFullScreen = this.onExitFullScreen.bind(this);        
    };
    
    playerUrl: string;
    defaultWidth: string;
    defaultAspectRatio: string;

    componentDidMount() {
        this.props.fetchContent();
    };

    onEnterFullScreen(event: any) {
        console.log(event);
    };

    onExitFullScreen(event: any) {
        console.log(event);
    };

    render() {
        return (
            <div className="container video-block loader-wrapper">
                {this.props.video &&
                    <ReactJWPlayer
                        playerId={this.props.id}
                        playerScript={this.playerUrl}
                        file={this.props.video.videoUrl}
                        image={this.props.video.imageUrl}
                        isAutoPlay={this.props.video.autoPlay}
                        onEnterFullScreen={this.onEnterFullScreen}
                        onExitFullScreen={this.onExitFullScreen}
                        aspectRatio={ this.defaultAspectRatio }
                        customProps={ { width:this.defaultWidth } }
                    />
                }
                <LoaderComponent isActive={this.props.loading} isOverlay={true} />
                {this.props.errorMessage &&
                    <AlertComponent message="Fetching data error. Please try again!" type="error" />
                }
            </div>
        );
    }
}

export default VideoBlockComponent;

On page scroll issue

Hi,
I am using you extension in my react project. Everthing is working fine but on my viewport screen there are my 2 Videos.i want to run only one autoplay but now what is happing its running both in same time i want only one video should play at same when i scroll then second should play or pervious one should pause.

Second issus is - if i mute the video and after scrolling video is pause automatically it running.it should pause after scroll. in case of mute on.

Google Analytics

The JWPlayer has a paramter for Google Anaytlics:

var playerInstance = jwplayer("myElement");
playerInstance.setup({
    file: "/uploads/example.mp4",
    image: "/uploads/example.jpg",
    ga: {} 
});

Is there any likelihood of being able to do the same with this implementation?

player.on is not a function

No initialize, o componente não está reconhecendo as chamadas de player.on:

player.on('beforePlay', _onBeforePlay);
player.on('ready', component.props.onReady);
player.on('setupError', component.eventHandlers.onError);
...

Tentei alterar cada chamada para o nome da função, e algumas funcionaram, mas o player continua com erro. Ex:
player.on('beforePlay'...) para player.onBeforePlay('beforePlay')

Não consegui localizar onde o player deveria chamar essas funções.
Agradeço ajuda.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.