HTML oncanplay Event Attribute

Description

The event attribute oncanplay is triggered when the browser can start playing the selected media file (when the file is sufficiently buffered, but not yet completely).

Syntax

<element oncanplay="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Событие oncanplay (элемент audio)</title>
</head>
<body>

<audio id="myAudio" controls oncanplay="myFunction()">
  <source src="audio.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</video>

<script>
function myFunction() {
    alert("Audio file ready to play");
}
</script> 

<p>Demonstration of the "oncanplay" attribute in the AUDIO element.</p>

</body>
</html>

Supported Tags

<audio>, <embed>, <object> and <video>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
XXYesYesXX
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYesYesXXX