Easy Tutorial
❮ Dom Obj Menu Dom Obj Base ❯

Video autoplay Attribute

Video Object

Example

Check if the video starts playing after it is ready:

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

Definition and Usage

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

This attribute reflects the HTML <video> autoplay attribute.

When present, it specifies that the video will start playing automatically once it is loaded.

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


Browser Support

All major browsers support the autoplay attribute.

Note: The <video> element is not supported in Internet Explorer 8 and earlier versions.


Syntax

Return the autoplay attribute:

Set the autoplay attribute:

Attribute Values

Value Description
true false Describes whether the audio or video should play automatically after the page loads. <br> true - Indicates that the audio or video should play immediately after loading. <br> false - Default. Indicates that the audio or video should not play immediately after loading.

Technical Details

Return Value: Boolean. Returns true if the video starts playing, otherwise returns false
Default Value: false
--- ---

More Examples

Example

Disable autoplay and reload the video:

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

Example

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

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

Related Pages

HTML Reference: HTML <video> autoplay Attribute


❮ Dom Obj Menu Dom Obj Base ❯