Video/audio timeupdate event triggers granularity (update frequency) adjustment

Generally speaking, the bottom layer of the video progress bar is updated every 250 milliseconds by default.

So the trigger frequency of this timeupdate event is also triggered every 250 milliseconds. How to increase this frequency?
In fact, you can add a timer to it.


Once the listener is triggered, it will be executed immediately in 5 times, once every 50 milliseconds, and executed 5 times, which is exactly 250 milliseconds.

video.addEventListener('timeupdate', function () {
      let count = 5
      let timer = setInterval(function () {
        console.log(video.currentTime)
        if (count == 0){
          clearInterval(timer)
        }else{
          count--;
        }
      },50)
    });

Guess you like

Origin blog.csdn.net/weixin_42333548/article/details/131111043