W3cubDocs

/DOM

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).

This is the least-worst way to automatically play media content. In most cases, you shouldn't automatically play content at all, instead allowing the user to control when playback begins. However, if you need this functionality, use autoplay to do so.

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

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/autoplay