Issue setting currentTime in HTML5 video

后端 未结 4 479
清酒与你
清酒与你 2020-12-11 14:40

I have a video in the middle of my html. As you can see at first I haven\'t any source

4条回答
  •  半阙折子戏
    2020-12-11 15:36

    You don't have to wait for it to start playing, but it does have to be ready to play. There's the canplay event to do that, so something like this should work:

    myVid.play();
    myVid.addEventListener('canplay', function() {
        this.currentTime = 5;
    });
    

提交回复
热议问题