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 Property na currentTimeUsed 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()">

Try it yourself

Example 2

Execute JavaScript when the current playback position of the audio changes:

<audio ontimeupdate="myFunction()">

Try it yourself

Example 3

Use the currentTime property to set the current playback position to 5 seconds:

document.getElementById("myVideo").currentTime = 5;

Try it yourself

Syntax

In HTML:

<element ontimeupdate="myScript">

Try it yourself

In JavaScript:

object.ontimeupdate = function(){myScript};

Try it yourself

In JavaScript, use the addEventListener() method:

object.addEventListener("timeupdate", myScript);

Try it yourself

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> at <video>
DOM Version: Level 3 Events

Suporta ng Browser

Ang mga numero sa talahanayan ay nagtutukoy sa unang bersyon ng browser na ganap na sumusuporta sa event na iyon.

Events Chrome IE Firefox Safari Opera
ontimeupdate Suporta 9.0 Suporta Suporta Suporta