Audio autoplay Property
Example
Find out if the audio started to play as soon as it was ready:
 var x = document.getElementById("myAudio").autoplay;
Try it Yourself »
Definition and Usage
The autoplay property sets or returns whether the audio should start playing as soon as it is loaded.
This property reflects the <audio> autoplay attribute.
When present, it specifies that the audio should automatically start playing as soon as it is loaded.
Browser Support
| Property | |||||
|---|---|---|---|---|---|
| autoplay | Yes | Yes | Yes | Yes | Yes | 
Syntax
Return the autoplay property:
 audioObject.autoplay
Set the autoplay property:
 audioObject.autoplay = true|false
Property Values
| Value | Description | 
|---|---|
| true|false | Specifies whether an audio should automatically start playing as soon as it is loaded 
 | 
Technical Details
| Return Value: | A Boolean, returns true if the audio automatically starts playing, otherwise it returns false | 
|---|---|
| Default Value: | false | 
More Examples
Example
Enable autoplay, and reload the video:
 var
 x = document.getElementById("myAudio");
x.autoplay = true;
 x.load();
Try it Yourself »
Example
A demonstration of how to create a <video> element and setting the autoplay property:
 var x = document.createElement("AUDIO");
Try it Yourself »
Related Pages
HTML reference: HTML <audio> autoplay attribute
❮ Audio Object
 
 
