小编Дим*_*нов的帖子

HTML5视频currentTime在Chrome中无效

我正在尝试制作自己的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.为什么?

javascript html5 google-chrome

6
推荐指数
0
解决办法
808
查看次数

标签 统计

google-chrome ×1

html5 ×1

javascript ×1