我正在尝试制作自己的HTML5视频播放器,我正在使用此代码更改视频的当前时间:
$(document).ready(function(){
...
//controls.total is my seekbar
controls.total.click(function(e) {
var x = e.pageX;
var prog = $(this);
var maxduration = video.duration;
var position = x - prog.offset().left;
var percentage = 100 * position / prog.width();
if(percentage > 100) {
percentage = 100;
}
if(percentage < 0) {
percentage = 0;
}
controls.progress.css('width',percentage+'%');
if ( video.seekable.length > 0 ) {
video.currentTime = maxduration * percentage / 100;
}
});
...
}
Run Code Online (Sandbox Code Playgroud)
它的工作方式与IE9,Edge和Firefox一样.但它在Chrome中不起作用.它只是将currentTime设置为0.为什么?