HTML5 Video Player Progress Bar Update

☆樱花仙子☆ 提交于 2020-01-13 13:53:43

问题


I've been following thenewboston's HTML5 video tutorial and have reached the tutorials where we make the video player. I've copied the code exactly but the progress bar doesn't update when it is clicked.

My JSFiddle

I think the reason this isn't working is because of something wrong with:

function clickedBar(e){
    if(!myMovie.paused && !myMovie.ended){
        var mouseX=e.offsetX;
        var newtime=mouseX*myMovie.duration/barSize;
        myMovie.currentTime=newtime;
        progressBar.style.width=mouseX+'px';
    }
}

I really can't figure out why it's not working but any help will be appreciated!

EDIT: Fixed Link.


回答1:


your code is working change

 bar.addEventListener('click', **clickedbar**, false);
 bar.addEventListener('click', clickedBar, false);

http://jsfiddle.net/wqr7S/4/



来源:https://stackoverflow.com/questions/23884899/html5-video-player-progress-bar-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!