Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Player add custom play button and overlay img

I'm using ReactPlayer plugin for my react website. I want to add custom play button and overlay image over the vimeo video follow the below image.

When I click play button overlay image and button need to hide and video start play.

Player Link here: https://jsfiddle.net/e6w3rtj1/

picture

<section className="vm-video">
    <div className="play-btn" onClick={this.handlePlayPause}>{playing ? 'Pause' : 'Play'}>
        <div className="arrow"></div>
    </div>
    <div className="video-preview">
        <img src={videopreviewpic} className="img-fluid" alt="video-preview-img" />
    </div>
    <div className="vc-container player-wrapper">
        <ReactPlayer onPlay={this.handlePlay} url='https://vimeo.com/361808343' className="react-player" controls width='100%' height='100%' />
    </div>
</section>
like image 998
Saravana Avatar asked Mar 17 '20 07:03

Saravana


1 Answers

  • Use the playIcon prop for the play button. This can be a JSX element.
  • Pass the poster image URL to light prop.

Example

<ReactPlayer
  url="https://vimeo.com/243556536"
  width="100%"
  height="500px"
  playing
  playIcon={<button>Play</button>}
  light="https://i.stack.imgur.com/zw9Iz.png"
/>
like image 200
Oscar Barrett Avatar answered Oct 10 '22 12:10

Oscar Barrett