thedaviddias/Front-End-Checklist / skills/autoplay-media
autoplay-media
VerifiedUse when reviewing rendered HTML, interactive components, or design-system patterns related to Avoid autoplaying media. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 2.0 KB |
| references/rule.md | markdown | 3.6 KB |
references/rule.md
View on GitHub# Avoid autoplaying media
> Audio and video content does not autoplay, or provides immediate controls to pause or stop playback.
**Priority:** high · **Difficulty:** beginner · **Time:** 10 min
---
Autoplaying media disrupts screen readers and startles users. Always require user interaction to start audio.
## Code Example
```html
<!-- ❌ Bad: Autoplay with audio -->
<video autoplay src="video.mp4"></video>
<!-- ✅ Acceptable: Autoplay muted (background video) -->
<video autoplay muted loop playsinline src="hero-bg.mp4"></video>
<!-- ✅ Best: No autoplay, user controls -->
<video controls src="video.mp4">
<track kind="captions" src="captions.vtt" srclang="en" label="English">
</video>
```
## Why It Matters
Autoplaying audio drowns out screen reader speech, startles users, and wastes bandwidth—providing user control is essential for accessibility and good UX.
## Accessible Video Player
```tsx
function VideoPlayer({ src, poster }) {
const [isPlaying, setIsPlaying] = useState(false)
const [isMuted, setIsMuted] = useState(true)
const videoRef = useRef
<video
ref={videoRef}
src={src}
poster={poster}
muted={isMuted}
playsInline
/>
<div className="controls">
<button
onClick={togglePlay}
aria-label={isPlaying ? 'Pause video' : 'Play video'}
>
{isPlaying ? : }
</button>
<button
onClick={() => setIsMuted(!isMuted)}
aria-label={isMuted ? 'Unmute video' : 'Mute video'}
>
{isMuted ? : }
</button>
</div>
</div>
)
}
```
## Background Video with Stop Button
```tsx
function HeroWithVideo() {
const [isPlaying, setIsPlaying] = useState(true)
const videoRef = useRef
<source src="hero.mp4" type="video/mp4" />
</video>
{/* Prominent pause control */}
<button
onClick={toggleVideo}
className="video-control"
aria-label={isPlaying ? 'Pause background video' : 'Play background video'}
>
{isPlaying ? 'Pause' : 'Play'} Background
</button>
<div className="hero-content">
<h1>Welcome</h1>
</div>
</section>
)
}
```
## WCAG Requirements
| Criterion | Requirement |
|-----------|-------------|
| 1.4.2 Audio Control | Audio that plays automatically for more than 3 seconds must have pause/stop/mute controls |
| 2.2.2 Pause, Stop, Hide | Moving content must have a mechanism to pause, stop, or hide |
## Exceptions
- Evaluate the rendered experience before treating a static-code smell as a blocker; interaction timing, browser behavior, and assistive technology output often determine severity.
- Not every secondary accessibility issue deserves equal weight; prioritize the issue that most directly blocks perception, operation, or understanding.
- Avoid adding redundant markup or ARIA solely to satisfy a rule when a simpler semantic implementation would eliminate the issue entirely.
## Standards
- Align the implementation with W3C WAI: WCAG Overview and verify the rendered experience, not only the source code.
- Align the implementation with MDN: Accessibility and verify the rendered experience, not only the source code.
## Verification
### Automated Checks
- Use browser accessibility tooling, axe, Lighthouse, or equivalent automated checks against a representative rendered state.
### Manual Checks
- Load page and verify no unexpected audio plays
- If video autoplays, confirm it's muted
- Check pause controls are keyboard accessible (early in tab order)
- Verify screen reader can announce and interact with controlsRelated skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |