HTML5 video - not setting the current time

亡梦爱人 提交于 2019-12-12 02:26:17

问题


This is driving me nuts!

video.addEventListener 'ended', (e) =>
    e.target.currentTime = 0
    console.log e.target.currentTime
    # 5.33 seconds NOT 0

The video plays, and the ended event is called, but the currentTime is not changed.


回答1:


This may be able to help you:

video = document.getElementById('video');
begin_play  = 50;
play_video_frist = true; //if you want to run only frist time    
video.addEventListener("play", capture, false);

function capture(event) 
{
     if (event.type == "play") {
         if (play_video_frist) {
             play_video_frist = false;
             video.currentTime = begin_play;
          }
     }
}


来源:https://stackoverflow.com/questions/14746384/html5-video-not-setting-the-current-time

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