HTML Audio/Video DOM seekedEvents

HTML Audio/Video DOM Reference Manual

Example

Display a prompt text when the user finishes setting the video's replay position:

var vid = document.getElementById("myVideo");
vid.onseeked = function() {
    alert("Seek operation completed!");
};

Try it Yourself »

More examples are included at the bottom of this article.


Definition and Usage

The seeked event is triggered when the user has moved/jumped to a new position in the audio/video.

Tip:The opposite event of the seeked event isseekingEvent.

Tip:Using Audio/Video objectscurrentTimeUse the attribute to get the video playback position.


Browser Support

The numbers in the table indicate the version number of the first browser that supports the event.

Events
seeked Yes 9.0 Yes Yes Yes


Syntax

In HTML:

<audio|video onseeked="myScript">Try it Yourself

In JavaScript:

audio|video.onseeked=function(){myScript};Try it Yourself

In JavaScript, using the addEventListener() method:

audio|video.addEventListener("seeked", myScript);Try it Yourself

Note:Internet Explorer 8 and earlier IE versions do not supportaddEventListener()method.


Technical Details
Supported HTML tags: <audio> and <video>
Supported JavaScript objects: Audio, Video


Examples

More Examples

Example

This example demonstrates the difference between the seeking event and the seeked event:

<video onseeking="myFunction()" onseeked="mySecondFunction()">

Try it Yourself »

Example

When the user finishes moving/jumping to a new video position, use the Video object's currentTime property to display the current playback position:

// Get the <video> element with id="myVideo"
var vid = document.getElementById("myVideo");

// Add a seeked event to <video>, execute the function after the seek operation is completed
vid.addEventListener("seeked", myFunction);

function myFunction() {
// Display the current playback position of <video> in the p element with id="demo"
    document.getElementById("demo").innerHTML = vid.currentTime;
}

Try it Yourself »

Example

Pop up a prompt message when the user finishes moving/jumping to a new audio playback position:

var aud = document.getElementById("myAudio");
aud.onseeked = function() {
    alert("Seek operation completed!");
};

Try it Yourself »


HTML Audio/Video DOM Reference Manualother extensions