Latest web development tutorials
 

Video autoplay Property

< Video Object

Example

Find out if the video started to play as soon as it was ready:

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

The result of x will be:

true
Try it Yourself »

Definition and Usage

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.

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


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The autoplay property is supported in all major browsers.

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


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
  • true - Indicates that the video should start playing as soon as it is loaded loaded
  • false - Default. Indicates that the video should NOT 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