How to stop video or audio from playing sound automatically?
no-autoplay-audio page
The issue
Sound that starts by itself talks over a screen reader, so the person using it can’t hear the page, or hear how to find the control that would stop it. For anyone else it is at best a surprise, and in an office or on a train it sends people away.
The cause is a <video> or <audio> element with the autoplay attribute, no muted attribute and no controls. WCAG 1.4.2, Audio Control, requires a way to pause or stop audio that plays for more than three seconds, or to control its volume separately.
Scope
Each visible <video> and <audio> element with autoplay is checked:
- With
muted, it passes. - With
controlsand nomuted, probeo can’t tell how long the sound plays, so it isn’t reported. Check those by hand. - With neither, it is reported.
How to check you have it
- In probeo: the page reports the
no-autoplay-audiorule, “<video>or<audio>elements must not play automatically”, with moderate impact, on each element that autoplays withoutmutedorcontrols. - By hand: search the page source for
autoplay, then load the page and listen. - With a tool: axe DevTools reports the same rule id.
The fix
Don’t autoplay sound: mute the media, or let the user start it.
A background or hero video can autoplay if it is muted, and it should still have a way to pause it. Media with meaningful sound should start when the user presses play.
<!-- Background video -->
<video autoplay muted loop playsinline src="hero.mp4"></video>
<!-- Media with sound -->
<video controls src="walkthrough.mp4"></video>Done when: no media plays sound automatically without a way to stop it, and the check above comes back clean.
Do not
- Do not rely on browsers blocking autoplay; their policies differ and change.
- Do not start audio from script on page load as a way around the attribute.
FAQ
Is a muted autoplay video fine?
For this rule, yes. Moving content that lasts more than five seconds still needs a way to pause it under WCAG 2.2.2.
Why isn’t autoplay with controls reported?
With controls the user can stop it, and whether that is enough depends on how long the sound plays before they can reach them. Probeo can’t measure that from the page, so it leaves it for you to check.
Does it matter if the sound is under three seconds?
WCAG 1.4.2 applies to audio longer than three seconds. Probeo doesn’t measure duration, so a short clip that autoplays without muted or controls is still reported.
Which product detects this
Probeo checks this on every page of your site as part of Site Clarity. This page explains one instance; the product tells you every page that has it.