Latest web development tutorials

HTML DOM Video autoplay attribute

Video Object Reference Video Object

Examples

See if they are ready to start playing after the video:

var x = document.getElementById ( "myVideo") autoplay.;
x The output is:
true

try it"

Definition and Usage

autoplay property sets or returns whether the audio and video playback starts after loading.

This property reflects the HTML <video> autoplay attribute.

When present, it specifies after the video once loaded video will begin playing automatically.

Note: The <video> element is new in HTML5.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support autoplay attribute

Note: Internet Explorer 8 and earlier versions of IE do not support the <video> element.


grammar

Back autoplay attributes:

videoObject .autoplay

Set autoplay properties:

videoObject .autoplay = true | false

Property Value

value description
true | false It describes the play automatically after the page is loaded
  • true - Indicates audio and video playback immediately after loading is completed.
  • false - default. Indicates audio and video should not be played immediately after loading.

technical details

return value: Boolean value. If the video starts playing returns true, false otherwise
Defaults: false


More examples

Examples

Disable Autoplay, and reload the video:

var x = document.getElementById ( "myVideo");
x.autoplay = true;
x.load ();

try it"

Examples

The following example demonstrates how to create a <video> element and set autoplay properties:

var x = document.createElement ( "VIDEO");

try it"


Related Pages

HTML Reference Manual: HTML <Video> AutoPlay Properties


Video Object Reference Video Object