navigator.getAutoplayPolicy() tells you whether media or Web Audio can autoplay: allowed, allowed-muted, or disallowed. Learn type checks (mediaelement / audiocontext), per-element checks, the mute-to-autoplay pattern, five examples, and try-it labs.
01
Kind
Method
02
Returns
Policy string
03
Status
Experimental
04
Types
mediaelement / audiocontext
05
Or pass
video / audio / AudioContext
06
Results
allowed · allowed-muted · disallowed
Fundamentals
Introduction
Browsers often block surprise sound on page load. That is why videos with autoplay may start muted, wait for a click, or not start at all.
getAutoplayPolicy() gives your page a clear answer up front so you can mute a video, show a Play button, or leave autoplay alone — instead of guessing.
💡
Check early
MDN recommends calling this on page load (or before creating players), then configuring media from the result. There is no event when the policy later changes.
Concept
Understanding the getAutoplayPolicy() Method
Call with one argument — a type string, a media element, or an AudioContext.
Type "mediaelement" — broad policy for <video> / <audio>.
Type "audiocontext" — broad policy for Web Audio API players.
"allowed" — autoplay is allowed (including with sound).
"allowed-muted" — only inaudible / muted content may autoplay.
"disallowed" — autoplay is blocked; offer a play control.
A string: "allowed", "allowed-muted", or "disallowed".
Common patterns
JavaScript
// MDN: configure based on mediaelement policy
if (navigator.getAutoplayPolicy("mediaelement") === "allowed") {
// Do nothing. The content can autoplay.
} else if (navigator.getAutoplayPolicy("mediaelement") === "allowed-muted") {
// Mute the video so it can autoplay.
} else {
// Autoplay disallowed — add a play button.
}
// Per-element check
const video = document.getElementById("video_element_id");
if (navigator.getAutoplayPolicy(video) === "allowed-muted") {
video.muted = true;
}
Cheat Sheet
⚡ Quick Reference
Goal
Code
Feature detect
typeof navigator.getAutoplayPolicy === "function"
Video / audio type policy
navigator.getAutoplayPolicy("mediaelement")
Web Audio type policy
navigator.getAutoplayPolicy("audiocontext")
One video element
navigator.getAutoplayPolicy(video)
Possible results
allowed · allowed-muted · disallowed
Snapshot
🔍 At a Glance
Four facts to remember about navigator.getAutoplayPolicy().
Returns
string
Policy result
Status
Experimental
Feature-detect
Mute path
allowed-muted
Mute then autoplay
Fallback
Play button
If disallowed / missing
Compare
📋 Policy Results Side by Side
Result
Meaning
Typical UX
allowed
Autoplay OK (with sound)
Leave media as-is
allowed-muted
Only muted / silent autoplay
Set muted = true
disallowed
Autoplay blocked
Show Play control
Hands-On
Examples Gallery
Examples follow MDN Autoplay Policy Detection patterns. Prefer Try It Yourself — results differ by browser and whether the user has already interacted with the site.
📚 Getting Started
Detect the API and read the broad media-element policy.
Example 1 — Feature Detection
MDN-style support check before reading any policy.
JavaScript
if (!navigator.getAutoplayPolicy) {
console.log("navigator.getAutoplayPolicy() not supported.");
} else {
console.log("navigator.getAutoplayPolicy() is supported.");
}
navigator.getAutoplayPolicy() is part of the experimental Autoplay Policy Detection API. Support is limited across browsers. Always feature-detect, configure mute / Play UI from the result, and never assume audible autoplay will work.
✓ Experimental · Limited
Navigator.getAutoplayPolicy()
Returns allowed, allowed-muted, or disallowed for media / Web Audio autoplay.
LimitedExperimental
Google ChromeAutoplay Policy Detection where implemented
Limited
Microsoft EdgeFollow Chromium support
Limited
Mozilla FirefoxCheck compatibility — feature-detect
Limited
Apple SafariCheck compatibility — feature-detect
Limited
OperaFollow Chromium where available
Limited
Internet ExplorerNo getAutoplayPolicy support
Unavailable
getAutoplayPolicy()Limited
Bottom line: Detect getAutoplayPolicy, check mediaelement or audiocontext on load, mute when allowed-muted, and always offer a Play control when disallowed or unsupported.
Wrap Up
Conclusion
navigator.getAutoplayPolicy() is the experimental way to ask the browser whether media or Web Audio may autoplay. Detect it, read allowed / allowed-muted / disallowed, mute when needed, and always keep a Play button ready.
Prefer per-element checks before play() after interaction
❌ Don’t
Assume audible autoplay works everywhere
Skip a Play control when the API is missing
Expect a change event when policy updates
Pass unsupported object types (throws TypeError)
Rely on autoplay for critical instructions
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about getAutoplayPolicy()
Ask the browser before you autoplay — mute or show Play.
5
Core concepts
🎬01
Returns
policy string
Value
⚡02
Status
Experimental
Limited
🔊03
Muted path
allowed-muted
Mute
📹04
Types
mediaelement
audiocontext
🎯05
Fallback
Play button
UX
❓ Frequently Asked Questions
It returns a string describing whether autoplay is allowed, allowed only when muted (allowed-muted), or disallowed — for media elements / audio contexts as a type, or for a specific HTMLMediaElement or AudioContext.
MDN marks it Experimental. It is not Deprecated or Non-standard. Always feature-detect and keep a play-button fallback when the API is missing.
One of: "allowed", "allowed-muted", or "disallowed".
Autoplay is allowed only for inaudible media — no audio track, or audio that has been muted. Apps often mute a video so it can still autoplay.
MDN recommends calling on page load (or before creating media) to configure autoplay. There is no event when the policy changes after user interaction, so also check again before play if needed.
Passing "mediaelement" returns the broad type policy. Passing a video/audio element returns that item's policy, which can differ after the user has interacted with the page.
Did you know?
There is no event when autoplay policy changes after the user clicks around the page. MDN notes you can check anytime, but most apps only need a load-time check (plus another check right before calling play() if you want to be careful).