![]() |
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:
HTML
<script>
function myFunction() {
alert("Can play through video without stopping");
}
</script>
<video oncanplaythrough="myFunction()">
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:
The numbers in the table specify the first browser version that fully supports the event attribute.
<element oncanplaythrough="script">
Value | Description |
---|---|
script | The script to be run on oncanplaythrough |
Supported HTML tags: | All HTML elements, but is most common in media elements, like <audio>, <embed>, <img>, <object>, and <video> |
---|
It can play through video without stopping.
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>
It can play through audio without stopping.
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>
html event attributes |
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 |
Example of HTML oncanplaythrough Event Attribute | Media Events Attribute |
Definition and Usage of HTML oncanplaythrough Event Attribute | Media Events Attribute |
Browser Support of HTML oncanplaythrough Event Attribute | Media Events Attribute |
Syntax of HTML oncanplaythrough Event Attribute | Media Events Attribute |
Attribute Values of HTML oncanplaythrough Event Attribute | Media Events Attribute |
Technical Details of HTML oncanplaythrough Event Attribute | Media Events Attribute |
How to execute a JavaScript when a video can be played all the way through, without stopping | Media Events Attribute |
How to execute a JavaScript when an audio can be played all the way through, without stopping | Media Events Attribute |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | Media Events Attribute |
Uploaded by: | Admin |
Reffered: https://www.w3schools.com/tags/ev_oncanplaythrough.asp