onseeking
onseeking event
The onseeking
event in HTML occurs when a user starts a seek operation on a media element, like <audio>
or <video>
. This gives developers the ability to run actions or scripts while the media is in the process of seeking to a new position.
Syntax
In HTML
<element onseeking ="myScript">
In JS
object.onseeking = function(){myScript};
addEventListener()
function is used. In JavaScript, the
object.addEventListener("seeking ", myScript);
Example
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Events</h1>
<h2>The onseeking Event</h2>
<p>Assign an "onseeking" event to a video element:</p>
<video controls onseeking="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>Try to move to a new position in the video.</p>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML += "Seek operation began! ";
}
</script>
</body>
</html>
Values
Conclusion
The onseeking
event allows developers to respond when a user starts seeking to a new position in a media element. It provides a way to track or trigger actions during the seek process. This helps enhance interactivity and control over media playback.
onseeked
The onseeked event in HTML is triggered when the playback position of a media element has been updated, enabling scripts to take action once the seeking process is finished.
onstalled
The onstalled event in HTML is triggered when a media element fails to fetch data, signaling a loading problem that impacts playback.