The video tag plays the video, which is precisely controlled and paused at a certain point in time.

listens to the timeupdate method, and the resulting time value is a bit like a random number.
for example, if I want to pause the video at the exact time point of 60.33s, I cannot use the timeupdate method to achieve this function.
I can only judge whether the current time is greater than 60.33s. In fact, the progress of video playback has already exceeded 60.33s.
how can I pause at a precise point in time?

I want to make sure that the video starts at 0 and pauses when it reaches 60.33s, which will neither be advanced nor delayed.

Mar.25,2021

is so precise that it is impossible.
this is how I implement it. Define an additional variable. After this point in time, determine whether to pause (preview pop-up window and other requirements), pause (preview), and then continue to play.
is set to the unpaused (unpreviewed) state if it is less than this point in time.
for example, I have three pieces of data. Time represents the point of time to be paused, and hasView represents whether it has been read.

let list = [
    {time: 10, hasView: false},
    {time: 20, hasView: false},
    {time: 30, hasView: false},
]

Core Code

video.addEventListener('timeupdate', () => {
  list.forEach(e => {
    if (e.hasView && video.currentTime < e.time) {
      e.hasView = false
    }
    if (!e.hasView && video.currentTime >= e.time && myVid.currentTime < e.time + 0.5) { // 0.5s
      e.hasView = true
      myVid.pause()
    }
})

  1. unless this point in time is a frame point in time, there will not be such an accurate
  2. . The time point information in
  3. line video playback is a kind of metadata data, which is actually a key value, which can be used to locate the file data (the corresponding frame-- usually the intra-file offset of the Keyframe data header, rather than a random number).
  4. it's true that you can only judge and stop by comparison, but you don't have to be at 60.33. You need to calculate the exact time according to the frame rate of the video, and then compare it one frame in advance as the standard point.

to pause at 60.33, listen in timeupdate for more than 59.33 (60.33-1), and then calculate the difference between the current time and the target time. Then use the timer function to perform the pause, and the interval is the difference just calculated


video.currentTime = 60.33;
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e44110-44a9a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e44110-44a9a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?