Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Video autoplay Property

Video autoplay property

Video Object Reference The Video object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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
  • true - Indicates that the audio/video plays immediately after loading is complete.
  • false - Default. Indicates that the audio/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();

    Try it »

    Example

    The following example demonstrates how to create

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

    Try it »


    Related pages

    HTML Reference Manual: HTML


    Video Object Reference The Video object