onseeking Event
Example
Execute a JavaScript when the user starts moving/skipping to a new position in the video:
<video onseeking="myFunction()">
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The onseeking event occurs when the user starts moving/skipping to a new position in the audio/video.
Tip: The onseeking event is the opposite of the onseeked event.
Tip: Use the currentTime property of the Audio/Video Object to get the current playback position.
Browser Support
The numbers in the table specify the first browser version that fully supports the event.
Event | |||||
---|---|---|---|---|---|
onseeking | Yes | 9.0 | Yes | Yes | Yes |
Syntax
In JavaScript, using the addEventListener() method:
object.addEventListener("seeking", myScript);
Try it Yourself »
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
Technical Details
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <audio> and <video> |
DOM Version: | Level 3 Events |
More Examples
Example
This example demonstrates the difference between the onseeking event and onseeked event:
<video onseeking="myFunction()" onseeked="mySecondFunction()">
Try it Yourself »
Example
Using the currentTime property of the Video Object to display the current playtime position when the user starts to skip to a new position:
// Get the <video> element with id="myVideo"
var x =
document.getElementById("myVideo");
// Attach a seeking event to the
<video>, and execute a function if a seek operation begins
x.addEventListener("seeking", myFunction);
function myFunction() {
//
Display the current position of the video in a <p> element with id="demo"
document.getElementById("demo").innerHTML = x.currentTime;
}
Try it Yourself »
Example
Execute a JavaScript when the user starts moving/skipping to a new position in the audio:
<audio onseeking="myFunction()">
Try it Yourself »
Event Object