简体   繁体   中英

Html5 video.currentTime freezes player

I am trying to skip a video ahead, using currentTime .

I set my video up like this:

<style>
#video-player {
      display:inline-block;
      width:500px;
      height:358px;
      margin-left:20px;
}
</style>
<video id="video-player" controls autoplay>  
   <source src="messi.mp4" type="video/mp4">
</video>

Later on, I have a click event set up on a button.

    var video = document.getElementById('video-player');
    video.currentTime = parseInt(video.currentTime) - 2;

All I want that button to do is to move the video back 2 seconds in time.

But when I click, it either moves the video to the beginning to freezes it up.

So this is very strange, but the issue went away when I tested my code on a live url.

I was testing using a local Python web server where I encountered the problem. Hope this helps someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM