HTML Audio/Video DOM timeupdate Event
Example
//Accessing the element
var vid = document.getElementById("myVideo");
// Assign an ontimeupdate event to the video element, and execute a function if the current playback position has changed
vid.ontimeupdate = function() {myFunction()};
//Creating a function
function myFunction() {
// Display the current position of the video in a p element with id="demo"
document.getElementById("demo").innerHTML = vid.currentTime;
}
Meaning
The timeupdate event run when the current playback position has changed.
Standard Syntax
HTML:
<element ontimeupdate="myScript">
JavaScript:
object.ontimeupdate=function(){myScript};
JavaScript, using the addEventListener() method::
object.addEventListener("timeupdate", myScript);
Advertisement