10

i am using react-player for playing videos. Not sure if there are any better options, but this seems to do the job. The only issue i have is, that i need to get thumbnails for the videos. Any idea how i would go around it ?

If you know about some better option for playing videos in React web app with supported thumbnails, that would be also great.

<ReactPlayer                                                    
 className="videoFrame"
 url={url}
 playing
 controls
/>

Thanks

Edit: I ended up using the video itself as thumbnail and blocking all mouse events over it. Then use parent div as button. In case of youtube i replace the video with thumbnail provided by youtube ( https://img.youtube.com ), because of the big play button over video. Most of other players dont have it.

CosmicSeizure
  • 1,375
  • 5
  • 17
  • 35
  • As a workaround you could display and img tag that you can hide when the video starts playing. Only issue would be to create the image tho – Dinosan0908 Oct 16 '18 at 11:21
  • Yeah, thats the hard part :) i realy dont know how to go around creating the thumbnail images for all the possible video services ( youtube, vimeo, dailymotion etc. ) – CosmicSeizure Oct 16 '18 at 11:27
  • just checked and found this https://www.npmjs.com/package/react-video-thumbnail might help you. Given URL returns you a thumbnail – Dinosan0908 Oct 16 '18 at 11:30

4 Answers4

12

Use the light prop to supply an image URL to the player.

<ReactPlayer                                                    
 className="videoFrame"
 url={url}
 light="http://placekitten.com/200/300"
 playing
 controls
/>
RubbelDieKatz
  • 1,134
  • 1
  • 15
  • 32
3

If you have an specific image that you want to be the thumbnail, you should set the image URL to light:

 <ReactPlayer                                              
       url='https://vimeo.com/243556536'
       light = 'https://sampleimage.com'
       playing
       controls/>

If you want to display the thumbnail of the video, you'll just have to set light to true:

<ReactPlayer                                              
      url='https://vimeo.com/243556536'
      light = {true}
      playing
      controls/>

Check the documentation of react-player on this link: https://www.npmjs.com/package/react-player

Jeanne vie
  • 518
  • 6
  • 12
0

You need to capture first frame of video as image than save it and use. But this used when you are working with image processing. I am recommending following options Please check here- https://www.npmjs.com/package/react-player otherwise use go through this link- https://video-react.js.org/

0

If you are trying to add a pester image, then they have something built-in.

    <Player
      poster="/assets/poster.png"
      src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4"
    />

here is where i found it . I was looking for somthing els, came aross this and then your post, so I thought I'd share it.

shmuel
  • 101