HTML | DOM Audio autoplay Property
The Audio autoplay property is used for setting or returning whether audio should start playing as soon as it is loaded or not.
It can be used to specify that the audio should automatically start playing as soon as it is loaded.
- Return the autoplay property:
- Set the autoplay property:
audioObject.autoplay = true|false
- true|false: It is used to specify whether an audio should automatically start playing as soon as it is loaded or not.
Return Values: It returns a Boolean value, that returns true if the audio automatically starts playing, otherwise it returns false
Below program illustrates the Audio autoplay Property:
Example: Enabling autoplay for an audio.
- Before clicking the button:
- After clicking the button:
Supported Browsers: The browser supported by HTML | DOM Audio autoplay Property are listed below:
- Google Chrome
- Internet Explorer
- Apple Safari