micnews / react-jw-player

A React Component API for JW Player
195 stars 94 forks source link

How to implement play() method #156

Open RaviAtTTN opened 4 years ago

RaviAtTTN commented 4 years ago

Hi, I want to add custom props "shouldPlay". If shouldPlay === true, then I want to play that Jw player otherwise not. Thus I need to call .play() method of jw player while checking the currebt value of shouldPlay. How would I achieve it?

RaviAtTTN commented 4 years ago

Currently my _initialize() method is:

_initialize() {
    const component = this;
    const player = window.jwplayer(this.videoRef);
    const playerOpts = getPlayerOpts(this.props);

    initialize({ component, player, playerOpts });
    if (this.props.shouldPlay) {
      console.log('hello player', player);
      player.play();
    }
  }

And I am getting this:-> Screenshot from 2019-12-16 17-18-06