Advertisement
Home Open Editor ❯

HTML Audio/Video DOM canplay Event

Example

//Accessing the element
var vid = document.getElementById("myVideo");

//Creating a function
vid.oncanplay = function() {
  alert("The video can start playing");
};

Try this code ❯

Meaning

The canplay event run when the browser can start playing the audio/video.


Standard Syntax

HTML:

<element oncanplay="myScript">

JavaScript:

object.oncanplay=function(){myScript};

JavaScript, using the addEventListener() method::

object.addEventListener("canplay", myScript);


Advertisement

Technical Details

Type Description
Supported HTML tags: <audio> and <video>
Supported JavaScript objects: Audio, Video
Home Open Editor ❯
Advertisement