HTML Audio/Video DOM seekingEvents

HTML Audio/Video DOM Reference Manual

Example

Pop up text information when the user starts moving/jumping to a new video playback position:

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

Try it Yourself »

This article contains more examples at the bottom.


Definition and Usage

The seeking event is triggered when the user starts moving/jumping to a new audio/video playback position.

Tip:The opposite event of the seeking event isseekedEvent.

Tip:Use of Audio/Video objectscurrentTimeAttribute to get the playback position.


Browser Support

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

Events
seeking Yes 9.0 Yes Yes Yes


Syntax

In HTML:

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

In JavaScript:

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

In JavaScript, using the addEventListener() method:

audio|video.addEventListener("seeking", 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 starts moving to a new position, use the currentTime property of the Video object to display the current playback position:

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

// Add seeking event to <video>, if seeking starts, execute the function
vid.addEventListener("seeking", myFunction);

function myFunction() {
// Display the 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 the new audio playback position:

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

Try it Yourself »


HTML Audio/Video DOM Reference Manualother extensions