Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html> 
<html> 
<body> 
<h1>HTML DOM Events</h1>
<h2>The ontimeupdate</h2>
<p>Attach a "timeupdate" event to a video element.</p>
<p>When the user plays the video, or skips to a new position, a function will display the position (in seconds) of the playback:</p>
<video id="myVideo" width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video><br>
<button onclick="setCurTime()" type="button">Set time position to 5 seconds</button>
<p id="demo"></p>
<script>
// Get the video element:
const video = document.getElementById("myVideo");
// Attach a "timeupdate" event to the video
video.addEventListener("timeupdate", getCurTime);
// Display the current playback position:
function getCurTime() { 
  document.getElementById("demo").innerHTML = "The playback position is " + video.currentTime + " seconds.";
} 
// Set the current playback position to 5 seconds
function setCurTime() { 
  video.currentTime = 5;
} 
</script> 
</body> 
</html>