Horje
HTML oncanplaythrough Event Attribute
Definition and Usage The oncanplaythrough attribute fires when the browser estimates it can play through the specified audio/video without having to stop for buffering. During the loading process of an audio/video, the following event attributes occur, in this order: loadstart. durationchange.

Example of HTML oncanplaythrough Event Attribute

It Can play through video without stopping.
index.html
Example: HTML
 <script>
function myFunction() {
  alert("Can play through video without stopping");
}
</script>

<video oncanplaythrough="myFunction()"> 

Output should be:

Example of HTML oncanplaythrough Event Attribute

Definition and Usage of HTML oncanplaythrough Event Attribute

The oncanplaythrough attribute fires when the browser estimates it can play through the specified audio/video without having to stop for buffering.

During the loading process of an audio/video, the following event attributes occur, in this order:

  1. loadstart
  2. durationchange
  3. loadedmetadata
  4. loadeddata
  5. progress
  6. canplay
  7. canplaythrough

Browser Support of HTML oncanplaythrough Event Attribute

The numbers in the table specify the first browser version that fully supports the event attribute.

Browser Support of HTML oncanplaythrough Event Attribute

Syntax of HTML oncanplaythrough Event Attribute

<element oncanplaythrough="script">

Attribute Values of HTML oncanplaythrough Event Attribute

Value Description
script The script to be run on oncanplaythrough

Technical Details of HTML oncanplaythrough Event Attribute

Supported HTML tags: All HTML elements, but is most common in media elements, like <audio>, <embed>, <img>, <object>, and <video>

How to execute a JavaScript when a video can be played all the way through, without stopping

It can play through video without stopping.

index.html
Example: HTML
<!DOCTYPE html> 
<html> 
<body> 

<script>
function myFunction() {
  alert("Can play through video without stopping");
}
</script>

<video controls oncanplaythrough="myFunction()">
  <source src="https://download.samplelib.com/mp4/sample-5s.mp4" type="video/mp4">
  <source src="https://download.samplelib.com/mp4/sample-5s.mp4" type="video/ogg">
  Your browser does not support HTML5 video.
</video>

<p>Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>

</body> 
</html>

Output should be:

How to execute a JavaScript when a video can be played all the way through, without stopping

How to execute a JavaScript when an audio can be played all the way through, without stopping

It can play through audio without stopping.

index.html
Example: HTML
<!DOCTYPE html> 
<html> 
<body> 

<script>
function myFunction() {
  alert("Can play through audio without stopping");
}
</script>

<audio controls oncanplaythrough="myFunction()">
  <source src="https://download.samplelib.com/mp3/sample-3s.mp3" type="audio/ogg">
  <source src="https://download.samplelib.com/mp3/sample-3s.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body> 
</html>

Output should be:

How to execute a JavaScript when an audio can be played all the way through, without stopping




html event attributes

Related Articles
List of Media Events Media Events Attribute
HTML onabort Event Attrribute Media Events Attribute
HTML oncanplay Event Attribute Media Events Attribute
HTML oncanplaythrough Event Attribute Media Events Attribute
HTML ondurationchange Event Attribute Media Events Attribute
HTML onended Event Attribute Media Events Attribute

Single Articles
Example of HTML oncanplaythrough Event AttributeMedia Events Attribute
Definition and Usage of HTML oncanplaythrough Event AttributeMedia Events Attribute
Browser Support of HTML oncanplaythrough Event AttributeMedia Events Attribute
Syntax of HTML oncanplaythrough Event AttributeMedia Events Attribute
Attribute Values of HTML oncanplaythrough Event AttributeMedia Events Attribute
Technical Details of HTML oncanplaythrough Event AttributeMedia Events Attribute
How to execute a JavaScript when a video can be played all the way through, without stoppingMedia Events Attribute
How to execute a JavaScript when an audio can be played all the way through, without stoppingMedia Events Attribute

Type:
Develop
Category:
Web Tutorial
Sub Category:
Media Events Attribute
Uploaded by:
Admin


Reffered: https://www.w3schools.com/tags/ev_oncanplaythrough.asp