Home > OS >  Play video iframe with reactjs
Play video iframe with reactjs

Time:09-29

enter image description hereThere is an issue. I have a slider which contains 2 images and 1 video, I embedded video in an iframe. The question is how can I hide 2 buttons (next and prev) of slider when I play video and show back when video is paused.

CodePudding user response:

You should use this component wich has built-in onPlay and onStop functions that would allow you to display or not the arrows from the slider.

You can achieve this by using a state for the arrow attribute wich would be set to false when the video is playing and to true when it's not.

It would look something like this:

  <ReactPlayer 
    onPlay={this.handlePlay()}
    onPause={this.handlePause()}
    url='yourvideourl' />

Note: handlePlay() should set the state of your arrow state variable to true and handlePause() to false.

  • Related