HTML DOM Audio autoplay attribute
Examples
Check whether the audio is set immediately after loading player:
var x = document.getElementById("myAudio").autoplay;
x The output is:
true
try it"
Definition and Usage
autoplay property sets or returns whether the audio and video playback starts after loading.
This property reflects the <audio> autoplay attribute.
If the autoplay attribute, specify the audio playback immediately after loading.
Note: <audio> element is a new element in HTML5.
Browser Support
The autoplay property in all major browsers support
Note: Internet Explorer 8 and earlier versions of IE do not support the <video> element.
grammar
Back autoplay attributes:
audioObject .autoplay
Set autoplay properties:
audioObject .autoplay = true | false
Property Value
值 | 描述 |
---|---|
true|false | 设置音视频是否在加载后即开始播放。
|
technical details
return value: | Boolean value that, if you set the audio play automatically returns true, otherwise returns false. |
---|---|
Defaults: | false |
More examples
Examples
AutoPlay is enabled, and reload the video:
var x = document.getElementById ( "myAudio");
x.autoplay = true;
x.load ();
x.autoplay = true;
x.load ();
try it"
Examples
The following example demonstrates how to create a <video> element and set autoplay properties:
var x = document.createElement("AUDIO");
try it"
Related Pages
HTML Reference Manual: HTML <Audio> AutoPlay Properties