是否可以在 html5 video
中寻找特定点?显示在网页中?我的意思是,我可以输入一个特定的时间值(例如 01:20:30:045
)并让玩家控制( slider )移动到该点并从该点开始播放吗?
在旧版本的 Mozilla vlcplugin
我认为 seek(seconds,is_relative)
可以做到这一点方法..但我想知道这在 html 视频中是否可行。
编辑:
我用视频创建了页面并添加了如下的javascript。当我点击链接时,它会显示点击时间..但它不会增加播放位置..但会继续正常播放。
视频播放位置不应该改变吗?
html
<video id="vid" width="640" height="360" controls>
<source src="/myvid/test.mp4" type="video/mp4" />
</video>
<a id="gettime" href="#">time</a>
<p>
you clicked at:<span id="showtime"> </span>
</p>
javascript
$(document).ready(function(){
var player = $('#vid').get(0);
$('#gettime').click(function(){
if(player){
current_time=player.currentTime;
$('#showtime').html(current_time+" seconds");
player.currentTime=current_time+10;
}
});
}
);
请您参考如下方法:
您可以使用 v.currentTime = seconds;
寻求给定的位置。
引用:https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentTime