Latest web development tutorials

HTML Audio / Video DOM seeking event

HTML audio / video Tag Reference HTML Audio / Video DOM Reference

Examples

Pop-up text message when the user begins to move / jump to a new video playback position:

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

try it"

Bottom of this article contains more examples.


Definition and Usage

When seeking to trigger an event in the user begins to move / jump to the new audio / video (audio / video) playback position.

Tip: Instead event seeking event is seeked event.

Tip: Use the Audio / Video object currentTime property Gets playback position.


Browser Support

Figures in the table represent the first browser to support this version of events.

event
seeking Yes 9.0 Yes Yes Yes


grammar

In HTML:

<Audio | video onseeking = "myScript "> try

In JavaScript:

audio | video .onseeking = function () {myScript}; try

JavaScript, use the addEventListener () method:

audio | video .addEventListener ( "seeking" , myScript); try

Note: Internet Explorer 8 and earlier versions of IE do not support addEventListener () method.


technical details
Supported HTML tags: <Audio> and <video>
Supported JavaScript Objects: Audio, Video


Examples

More examples

Examples

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

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

try it"

Examples

When the user begins to move to a new location, use the Video object currentTime property displays the current playback position:

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

// For the <video> seeking to add an event, if you start addressing a function begins execution
vid.addEventListener ( "seeking", myFunction);

function myFunction () {
// Display id = "demo" of the p element <video> player positions
. Document.getElementById ( "demo") innerHTML = vid.currentTime;
}

try it"

Examples

A message appears upon completion of move / jump to the audio playback position in a new user:

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

try it"


HTML audio / video Tag Reference HTML Audio / Video DOM Reference