Video autoplayProperty

Video 对象参考手册Video Object

Examples

Check whether the video starts playing after it is ready:

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

Try it Yourself »

Definition and Usage

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

This property reflects the HTML <video> autoplay attribute.

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

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the autoplay property.

Note:Internet Explorer 8 and earlier IE 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 Describes that it will automatically play after the page is loaded.
  • true - Indicates that the audio/video will play immediately after loading is complete.
  • false - Default. Indicates that the audio/video should not play immediately after loading.

Technical Details

Return Value: Boolean value. Returns true if the video starts playing, otherwise 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 Yourself »

Example

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

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

Try it Yourself »


Related Pages

HTML Reference:HTML <video> autoplay attribute


Video 对象参考手册Video Object Other Extensions