ontimeupdate
Event
Example
Execute JavaScript when the current playback position changes:
<video ontimeupdate="myFunction()">
More examples are included at the bottom of this page.
Definition and Usage
The ontimeupdate event is triggered when the current playback position of the video/audio changes.
This event is invoked by:
- Playing the video/audio
- Seeking the playback position of the video/audio.
Tip: This event is commonly used with the currentTime property of the Video object, which returns the current playback position of the video/audio.
Browser Support
The numbers in the table specify the first browser version that supports the event.
Event | |||||
---|---|---|---|---|---|
ontimeupdate | Yes | 9.0 | Yes | Yes | Yes |
Syntax
In HTML:
In JavaScript:
In JavaScript, using the addEventListener() method:
Note: Internet Explorer 8 and earlier versions do not support the addEventListener() method.
Bubbles: | No |
---|---|
Cancelable: | No |
--- | --- |
Event Type: | Event |
--- | --- |
Supported HTML Tags: | <audio>, <video> |
--- | --- |
More Examples
Example
Execute JavaScript when the user starts playing the audio or seeks the audio playback position:
Example
Set the current playback position to 5 seconds using the currentTime property:
document.getElementById("myVideo").currentTime = 5;