Audio autoplay 属性
实例
例子 1
查看音频是否在准备好后立即开始播放:
var x = document.getElementById("myAudio").autoplay;
例子 2
启用自动播放,并重新加载视频:
var x = document.getElementById("myAudio"); x.autoplay = true; x.load();
例子 3
演示如何创建 <video> 元素并设置 autoplay 属性:
var x = document.createElement("AUDIO");
语法
返回 autoplay 属性:
audioObject.autoplay
设置 autoplay 属性:
audioObject.autoplay = true|false
属性值
值 | 描述 |
---|---|
true|false |
定义音频是否应在加载后立即开始播放。
|
Technische Details
Rückgabewert: | Boolscher Wert, wird true zurückgegeben, wenn das Audio automatisch abgespielt wird,否则返回 false。 |
---|---|
Standardwert: | false |
Browserunterstützung
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Unterstützung | Unterstützung | Unterstützung | Unterstützung | Unterstützung |
Verwandte Seiten
HTML-Referenzhandbuch:HTML <audio> autoplay-Attribut