How to set the thumbnail image on HTML5 video?

前端 未结 7 974
失恋的感觉
失恋的感觉 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:

    
    

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

提交回复
热议问题