ontimeupdate event
Definition and usage
The ontimeupdate event occurs when the playback position of the audio/video changes.
This event is triggered by the following situations:
- Play audio/video
- Move the playback position (for example, when the user fast forwards to a different point in the audio/video)
Tip:The ontimeupdate event is usually associated with the currentTime PropertyUsed together, this property returns the current playback position of the audio/video in seconds.
Instance
Example 1
Execute JavaScript when the current playback position changes:
<video ontimeupdate="myFunction()">
Example 2
Execute JavaScript when the current playback position of the audio changes:
<audio ontimeupdate="myFunction()">
Example 3
Use the currentTime property to set the current playback position to 5 seconds:
document.getElementById("myVideo").currentTime = 5;
Syntax
In HTML:
<element ontimeupdate="myScript">
In JavaScript:
object.ontimeupdate = function(){myScript};
In JavaScript, use the addEventListener() method:
object.addEventListener("timeupdate", myScript);
Note:Internet Explorer 8 or earlier versions do not support addEventListener() method.
Technical details
Bubbling: | Not supported |
---|---|
Cancelable: | Not supported |
Event type: | Event |
Supported HTML tags: | <audio> and <video> |
DOM Version: | Level 3 Events |
Browser Support
The numbers in the table indicate the first browser version that fully supports the event.
Events | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
ontimeupdate | Support | 9.0 | Support | Support | Support |