Video autoplay Property
Example
Find out if the video started to play as soon as it was ready:
var x = document.getElementById("myVideo").autoplay;
Try it Yourself »
Description
The autoplay property sets or returns whether a video should start playing as soon as it is loaded.
This property reflects the <video> autoplay attribute.
When present, it specifies that the video should automatically start playing as soon as it is loaded.
Browser Support
Property | |||||
---|---|---|---|---|---|
autoplay | Yes | 9.0 | Yes | Yes | Yes |
Syntax
Return the autoplay property:
videoObject.autoplay
Set the autoplay property:
videoObject.autoplay = true|false
Property Values
Value | Description |
---|---|
true|false | Specifies whether a video should automatically start playing as soon as it is loaded
|
Technical Details
Return Value: | A Boolean, returns true if the video automatically starts playing, otherwise it returns false |
---|---|
Default Value: | false |
More Examples
Example
Enable autoplay, and reload the video:
var x = document.getElementById("myVideo");
x.autoplay = true;
x.load();
Try it Yourself »
Example
A demonstration of how to create a <video> element and setting the autoplay property:
var x = document.createElement("VIDEO");
Try it Yourself »
Related Pages
HTML reference: HTML <video> autoplay attribute
❮ Video Object