Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

play()

This article needs a technical review. How you can help.

 

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The HTMLMediaElement.play() method attempts to begin playback of the media and returns a Promise which is fulfilled when the playback has been successfully started, and which is rejected if playback fails to begin for any reason (such as permission issues or other problems).

Syntax

HTMLMediaElement.play().then(function() { ... }

Parameters

None.

Return value

A Promise which is fulfilled when playback has been started, or is rejected if for any reason playback cannot be started.

Exceptions

The promise's rejection handler is called with an exception as its input value (as opposed to a traditional exception being thrown). Possible exceptions include:

NotAllowedError
The user agent (browser) or operating system doesn't allow playback of media in the current context or situation. This may happen, for example, if the browser requires the user to explicitly start media playback by clicking a "play" button.
NotSupportedError
The media source (which may be specified as a MediaStream, MediaSource, Blob, or File, for example) doesn't represent a supported media format.

Other exceptions may be reported, depending on browser implementation details, media player implementation, and so forth.

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'play()' in that specification.
Living Standard Initial definition; living specification.
HTML5
The definition of 'play()' in that specification.
Recommendation Initial definition.

Note that the WHATWG and W3C versions of the specification differ (as of April 20, 2016) as to whether or not this method returns a Promise or nothing at all, respectively.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 50.0 3.5 (1.9.1) ? ? ?
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 50.0 (Yes) ? ? ? ? 50.0

Document Tags and Contributors

 Contributors to this page: jpmedley, Sheppy, dgashmdn
 Last updated by: jpmedley,