Dostępność
a11y/no-autoplay-audio
No audio plays automatically; autoplaying video is muted, and any sound longer than 3 seconds can be paused or stopped.
umiarkowanastatyczneWCAG 1.4.2 · Afe-a11y-media
Dlaczego
Sound that starts on its own talks over a screen reader, so a blind user cannot hear the page well enough to find the control that stops it. Browsers also block most unmuted autoplay, so the feature is unreliable anyway.
Poprawka
Start media only when the person presses play. A decorative autoplaying video gets muted (and playsinline on iOS). If audio must start by itself, stop it within 3 seconds or put a pause or mute control first on the page.
Przykłady
<!-- bad -->
<video autoplay src="promo.mp4"></video>
<!-- good -->
<video autoplay muted loop playsinline src="promo.mp4"></video>
<video controls src="promo.mp4"></video>Źródła
Fakty
- Identyfikator
a11y/no-autoplay-audio- Waga
- umiarkowana
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
htmlangularvuesvelteastrojsx- WCAG 2.2
- 1.4.2, poziom A
- Ten sam problem w
- axe-core
no-autoplay-audio - Uczy jej skill
fe-a11y-mediaMedia, motion and flashing- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain a11y/no-autoplay-audio