Detect in Javascript when HTML5 <video> loop restarts?

后端 未结 3 1810
一个人的身影
一个人的身影 2021-02-07 12:37

I have a looping HTML5 video using , and I want to know when the video loops. The event listener play only fires when the vi

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-07 12:55

    I think the most reliable way is to loop it yourself. Remove the loop attribute and do this:

    document.querySelector('video').addEventListener('ended', function () {
      console.count('loop restart');
      this.play();
    })

提交回复
热议问题