📚 Encyclopedia

Web Development · updated 2026-10-13

Web video players: sound, mute, fullscreen and autoplay-next

videoautoplayuser-activationfullscreeniosandroidlocalstorage

Browsers allow unmuted playback and fullscreen only while a user gesture is live. Most "the video has no sound on my phone" and "fullscreen does not work" bugs are about losing that gesture or about stored mute state. These are the rules learned building the player for videos.jhampton.io (one thin wrapper, player.js, around a single <video>), and they are Justin's standing rules for any player.

Sound only survives inside the gesture

A mute must always be reachable

There are two ways to be silent: video.muted and video.volume === 0. Both must be shown and both must be fixable. - Never hide the mute toggle at any viewport. "Phones have hardware volume" is half true: hardware keys change the level, they cannot clear a muted flag. Hide the volume slider on small screens if needed; keep the toggle. - Make the toggle mean sound on/off, not "flip muted": clear the mute and restore volume if it is zero. - If playback starts silent for any reason, show a persistent toast with the fix attached ("Sound is off, turn sound on"). No timeout on it. - Real case (2026-08-15): no sound on Justin's Android, but it worked in a private tab, which pointed straight at stored state. A remembered mute plus a hidden mute control at max-width: 560px plus a toggle that never touched volume compounded into permanent silence. Asking "does it behave differently in a private window?" is a great first question. - Storage keys used: jah-vp-muted, jah-vp-volume (0..1), jah-vp-pos-<slug> for resume position.

iOS audio session

iOS routes inline <video> through the ambient audio session, which the hardware silent switch mutes: picture and no sound, with nothing on screen to explain it. Before play():

if (navigator.audioSession) navigator.audioSession.type = 'playback';

Safari 16.4+, feature-detected, absent elsewhere. It looks like dead code on other browsers; do not remove it.

Fullscreen: touch only

Justin's rule: "The user explicitly took action to watch the video, therefore immersion should be prioritized over control." On touch devices (matchMedia('(hover: none)')), request fullscreen inside the tap. On desktop, do not: fullscreen there is a much bigger mode change than the click that asked for it, and double-click is enough. He accepted that split. - iPhone has no element fullscreen, only video.webkitEnterFullscreen(), which hands over to Apple's player. Skip it for videos whose rotation is done in CSS (Apple's player would show them sideways); see Rotating video in CSS instead of re-encoding. - Closing the overlay must exit fullscreen first. - The same rule applied to a canvas game (Joyride): on coarse pointers the "get in" tap also calls requestFullscreen (hide the button where unsupported, e.g. iPhone Safari).

Autoplay next in a series

Testing notes

See also

Linked from

Sources: justinahampton memory (videos-player-rules, videos-autoplay-next, justin-tests-on-a-real-android), global CLAUDE.md media player rules, 2026-08-15 and 2026-08-22