Javascript DOM oncanplaythrough Event

Introduction

Execute a JavaScript when a video can be played all the way through without stopping.

View in separate window

<!DOCTYPE html>
<html>
<body>

<video controls oncanplaythrough="myFunction()">
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>/*from   w ww .ja  va  2  s . co m*/

<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Can play through video without stopping";
}
</script>

</body>
</html>

The oncanplaythrough event occurs when the browser knows it can play through the specified media without having to stop for buffering.

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



PreviousNext

Related