'HTML5 video element "seeked" event

There are two events for seek in HTML video player.

  1. Seeking : Seek operation began
  2. Seeked : seek operation completed

For every corresponding seeking event we have seeked event. But In my project for some of seeking event, we are not getting the seeked event.

Here my question are:

  1. Why is it happening so that we are getting seeked event ?
  2. Is it possible that media player doesn't capture all events?


Solution 1:[1]

If a second seeking event occurs before the first seek operation is over, you will have only the last seeked event.

This may happen relatively easily with big video files e.g if the whole data is not prefetched, or when the user scrubs through the timeline controls.

let seeking = false;
vid.onseeking = e => {
  if (seeking) {
    // if we enter here it means we had a seeking event
    // that hasn't been matched by a seeked one
    console.log("already seeking");
  }
  seeking = true;
};
vid.onseeked = e => {
  seeking = false;
};

vid.play().then(() => {
  vid.currentTime = 10;
  vid.currentTime = 15;
});
video {
  height: 150px
}
<video controls id=vid src=https://upload.wikimedia.org/wikipedia/commons/2/22/Volcano_Lava_Sample.webm muted></video>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kaiido