--- title: 'Feature-Policy: autoplay' slug: Web/HTTP/Headers/Feature-Policy/autoplay translation_of: Web/HTTP/Headers/Feature-Policy/autoplay ---
The HTTP {{HTTPHeader("Feature-Policy")}} header autoplay
directive controls whether the current document is allowed to autoplay media requested through the {{domxref("HTMLMediaElement")}} interface. When this policy is enabled and there were no user gestures, the {{domxref("Promise")}} returned by {{domxref("HTMLMediaElement.play()")}} will reject with a DOMException
. The {{htmlattrxref("autoplay", "audio")}} attribute on {{HTMLElement("audio")}} and {{HTMLElement("video")}} elements will be ignored.
For more details on autoplay and autoplay blocking, see the article Autoplay guide for media and Web Audio APIs.
Feature-Policy: autoplay <可选>;
'self'
.参考说明 | 状态 | 注解 |
---|---|---|
{{SpecName('Feature Policy')}} | {{Spec2('Feature Policy')}} | Initial definition. |
{{Compat("http.headers.Feature-Policy.autoplay")}}