HTMLMediaElement.autoplay

The HTMLMediaElement.autoplay property reflects the autoplay HTML attribute, indicating whether playback should automatically begin as soon as enough media is available to do so without interruption.

A media element whose source is a MediaStream and whose autoplay property is true will begin playback when it becomes active (that is, when MediaStream.active becomes true).

Sites which automatically play audio (or videos with an audio track) can be an unpleasant experience for users, so it should be avoided when possible. If you must offer autoplay functionality, you should make it opt-in (requiring a user to specifically enable it). However, this can be useful when creating media elements whose source will be set at a later time, under user control.

Syntax

HTMLMediaElement.autoplay = true | false;

var autoplay = HTMLMediaElement.autoplay;

Value

A Boolean whose value is true if the media element will begin playback as soon as enough content has loaded to allow it to do so without interruption.

Examples

...

<...></...>

...

Xxx.xxx()

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'HTMLMediaElement.autoplay' in that specification.
Living Standard No change from HTML5
HTML5
The definition of 'HTMLMediaElement.autoplay' in that specification.
Recommendation Initial definition.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes)[1] (Yes) 3.5 (1.9.1) [1] 9 ? ?
Feature Android Edge Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) ? (Yes) (Yes)

[1] Some versions of Chrome call this property autostart, rather than autoplay.

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, erikadoyle, neaumusic, markg
 Last updated by: Sheppy,