如何从特定位置开始HTML 5视频

How to start a HTML 5 video from a particular position?

本文关键字:开始 HTML 视频 位置 定位      更新时间:2023-09-26
<video width="320" height="240" controls>
  <source src="Video.mp4#t=03,20" type="video/mp4">
  Your browser does not support the video tag.
</video>

视频开始从3分20秒在我的代码。我想在html5中设置#t=03,20后从头开始播放视频。我该怎么做呢?

<video id="vid1" width="320" height="240" controls loop>
  <source src="Video.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>

你必须等待,直到浏览器知道视频的持续时间,你才能搜索到一个特定的时间。

     <script>
      window.onload=function(){
                  document.getElementById('vid1').addEventListener('loadedmetadata', function() {
                  this.currentTime = 200;
            }, false  );
       };             
     </script>

function restart1() 
{ var video1 = document.getElementById("vid1");
 video1.currentTime = 0; 
} 
<video id="vid1" width="320" height="240" onclick="restart1();" controls> 
       <source src="Videos.mp4#t=03,61" type="video/mp4">
        Your browser does not support the video tag. 
</video>
相关文章: