onwaiting
onwaiting event
The onwaiting
event attribute activates a script when media playback is paused due to buffering or waiting for data. It's helpful for showing loading indicators or managing playback interruptions.
Syntax
In HTML
<element onwaiting ="myScript">
In JS
object.onwaiting = function(){myScript};
addEventListener()
function is used. In JavaScript, the
object.addEventListener("waiting ", myScript);
Example
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Events</h1>
<h2>The onwaiting Event</h2>
<p>Assign an "onwaiting" event to a video element:</p>
<video controls onwaiting="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>Play the video.</p>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Buffering";
}
</script>
</body>
</html>
Values
Example
This logs a message to the console when the <video>
playback is paused because of buffering.
Conclusion
The onwaiting
event is triggered when media playback is paused due to buffering or waiting for data. It allows developers to manage loading states, such as displaying a loading indicator. This enhances the user experience by handling interruptions in playback.
onvolumechange
The onvolumechange event in HTML is triggered when the volume of audio or video content is adjusted, allowing scripts to react to these changes in volume.
Mouse
HTML mouse event attributes trigger actions based on user interactions like clicks or movements, using attributes such as onclick, onmouseover, and onmousedown.