Video autoplay property
Example
Check whether to start playing the video once it is ready:
var x = document.getElementById("myVideo").autoplay;
x
The output is:
true
Try it »
Definition and Usage
The autoplay property sets or returns whether the audio/video starts playing immediately after loading.
This property reflects the HTML
When present, it specifies that the video will start playing automatically once it is loaded.
Note: The
Browser support





All major browsers support the autoplay property
Note: Internet Explorer 8 and earlier IE versions are not supported.
Syntax
Returns the autoplay attribute:
videoObject
.autoplay
Set the autoplay attribute:
videoObject
.autoplay=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes automatic playback after the page loads
|
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();
Try it »
Example
The following example demonstrates how to create
var x = document.createElement("VIDEO");
Try it »
Related pages
HTML Reference Manual: HTML
The Video object