blob: 88dc07c786fd6cb99afa3c513d99c264e9074a36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
---
title: 'Feature-Policy: autoplay'
slug: Web/HTTP/Headers/Feature-Policy/autoplay
translation_of: Web/HTTP/Headers/Feature-Policy/autoplay
---
<div>{{HTTPSidebar}} {{SeeCompatTable}}</div>
<p><span class="seoSummary">The HTTP {{HTTPHeader("Feature-Policy")}} header <code>autoplay</code> directive controls whether the current document is allowed to autoplay media requested through the {{domxref("HTMLMediaElement")}} interface.</span> When this policy is enabled and there were no user gestures, the {{domxref("Promise")}} returned by {{domxref("HTMLMediaElement.play()")}} will reject with a <code>DOMException</code>. The {{htmlattrxref("autoplay", "audio")}} attribute on {{HTMLElement("audio")}} and {{HTMLElement("video")}} elements will be ignored.</p>
<p>For more details on autoplay and autoplay blocking, see the article <a href="/en-US/docs/Web/Media/Autoplay_guide">Autoplay guide for media and Web Audio APIs</a>.</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">Feature-Policy: autoplay <可选>;</pre>
<dl>
<dt><allowlist></dt>
<dd>{{page("Web/HTTP/Feature_Policy/Using_Feature_Policy", "allowlist")}} 默认值是<code>'self'</code>.</dd>
</dl>
<h2 id="参考说明">参考说明</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">参考说明</th>
<th scope="col">状态</th>
<th scope="col">注解</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('Feature Policy')}}</td>
<td>{{Spec2('Feature Policy')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性支持">浏览器兼容性支持</h2>
<p>{{Compat("http.headers.Feature-Policy.autoplay")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li>{{HTTPHeader("Feature-Policy")}} header</li>
<li><a href="/en-US/docs/Web/HTTP/Feature_Policy">Feature Policy</a></li>
<li><a href="/en-US/docs/Web/HTTP/Feature_Policy/Using_Feature_Policy">Using Feature Policy</a></li>
</ul>
|