onseeked
onseeked event
The onseeked
event in HTML occurs when the playback position of a media element, like <audio>
or <video>
, is updated and the seek action is finished. This lets developers run specific actions or scripts after the user jumps to a new position in the media.
Syntax
In HTML
<element onseeked ="myScript">
In JS
object.onseeked = function(){myScript};
addEventListener()
function is used. In JavaScript, the
object.addEventListener("seeked ", myScript);
Example
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Events</h1>
<h2>The onseeked Event</h2>
<p>Assign an "onseeked" event to a video element.</p>
<p>Move to a new position in the video.</p>
<video controls onseeked="myFunction()">
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
<p>Video courtesy of <a href="https://institute.qarpeo.com" target="_blank">Tree</a>.</p>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Seek operation completed!";
}
</script>
</body>
</html>
Values
Conclusion
The onseeked
event allows developers to trigger actions when a user changes the playback position in a media element. It’s useful for updating the UI or executing scripts after the seek operation is complete. This enhances interactivity and control over media playback.
onratechange
The onratechange event in HTML is triggered when the playback rate of an audio or video element is modified, enabling developers to react to changes in playback speed.
onseeking
The onseeking event in HTML is triggered when a media element starts seeking to a new playback position, allowing scripts to respond to this action.