Advertisement
Home Open Editor ❯

HTML Audio/Video DOM autoplay Property

Example

var vid = document.getElementById("myVideo");

function enableAutoplay() {
  vid.autoplay = true;
  vid.load();
}

function disableAutoplay() {
  vid.autoplay = false;
  vid.load();
}

function checkAutoplay() {
  alert(vid.autoplay);
}

Try this code ❯

Meaning

The autoplay property sets or returns whether the audio/video should start playing as soon as it is loaded.


Standard Syntax

audio|video.autoplay=true|false


Advertisement

Return Value

Type Description
true Specifies that the audio/video should start playing as soon as it is loaded.
false Default. Specifies that the audio/video should NOT start playing as soon as it is loaded.

Technical Details

Return Value: A Boolean. Either true or false
Default Value: false
Home Open Editor ❯
Advertisement