Javascript DOM onwaiting Event

Introduction

Execute a JavaScript when the video stops because it needs to buffer the next frame:

This example demonstrates how to assign an "onwaiting" event to a video element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p>Play the video.</p>

<video controls onwaiting="myFunction()">
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>//from   ww  w .  j  a  va 2  s  . c  o m

<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Wait! I need to buffer the next frame";
}
</script>

</body>
</html>

The onwaiting event occurs when the video stops because it needs to buffer the next frame.

This event can also be used on <audio> elements, but it is mostly used for videos.

Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags: <audio>, <video>



PreviousNext

Related