2014-03-19 31 views
2
<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后从头开始播放视频。我怎样才能做到这一点?如何从特定位置启动HTML 5视频?

回答

3
<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> 

OR

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> 
+0

在这里我必须把你的代码 – user3232585

+0

把它放在''网页 –

+0

的部分有一个看看这个页面(http://gingertech.net/2009/08/19 /跳到时间偏移量在视频/)的细节。 –