How to set the thumbnail image on HTML5 video?

前端 未结 7 935
失恋的感觉
失恋的感觉 2020-11-30 20:38

Is there a way to set thumbnail image on HTML5 video? I want to see some pictures before play. My code looks like this:

相关标签:
7条回答
  • 2020-11-30 21:10

    1) add the below jquery:

    $thumbnail.on('click', function(e){
     e.preventDefault();
     src = src+'&autoplay=1'; // src: the original URL for embedding 
     $videoContainer.empty().append( $iframe.clone().attr({'src': src}) ); // $iframe: the original iframe for embedding
     }
    );
    

    note: in the first src (shown) add the original youtube link.

    2) edit the iframe tag as:

    <iframe width="1280" height="720" src="https://www.youtube.com/embed/nfQHF87vY0s?autoplay=1" frameborder="0" allowfullscreen></iframe>
    

    note: copy paste the youtube video id after the embed/ in the iframe src.

    0 讨论(0)
提交回复
热议问题