Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

video-player

Platform video player that wraps native <video> with custom overlay controls in shadow DOM. Progressive enhancement — native video works without JS.

Overview

A platform-native video player that wraps <video> in light DOM and renders custom overlay controls in shadow DOM. Controls fade in on interaction and auto-hide during playback. The native player is always the fallback — if JS is unavailable, <video controls> works normally with poster, captions, and fullscreen.

Single Video

Wrap a native <video> with optional <track> elements for captions.

Sizing

Always include width and height attributes on the <video> element. These give the browser intrinsic dimensions before metadata loads, preventing layout shift — the same best practice as <img>.

For remote or large video files, the browser may not have loaded metadata (and therefore the video's native dimensions) by the time the page renders. Without dimension hints, the player collapses to zero height until the remote file responds.

The component also applies aspect-ratio: 16/9 as a CSS fallback. Once the video's actual aspect ratio is known from metadata or the poster image, it overrides the CSS default automatically. If your video is not 16:9, the width/height attributes ensure the correct ratio is used from the start.

A poster image is strongly recommended — it provides visual content before playback and helps the browser establish dimensions early.

Playlist Mode

Include a <details> with <ol class="track-list"> inside the component. Clicking a track updates the video source and plays it. Use data-poster and data-captions on track links for per-video switching.

Shuffle and Loop

Controls Behavior

Unlike <audio-player> which shows a permanent control bar, video controls are an overlay that fades in and out:

  • Visible for 3 seconds after any interaction (mousemove, focus, keypress)
  • Never hidden while keyboard focus is inside the controls
  • Always visible when paused, before first play, or after ended
  • Touch devices: tap toggles visibility
  • Cursor hides when controls are hidden during playback
  • prefers-reduced-motion: controls stay permanently visible

A gradient scrim at the bottom ensures controls are readable over any video content.

Attributes

AttributeTypeDescription
autoplayBooleanStart playing when first connected (subject to browser autoplay policy). Skipped for users with prefers-reduced-motion: reduce, which also cancels a native autoplay on the inner <video>. Not re-run when the player is moved in the DOM.
loopBooleanSingle video: loop it. Playlist: wrap to the first track after the last
shuffleBooleanPlaylist: advance to a random other track
mutedBooleanStart muted (an authored <video muted> works too)
captionsBooleanStart with the first captions/subtitles track showing
data-label-*StringOverride any UI string; see Localization

Component-Managed Attributes

AttributeValuesDescription
stateidle, playing, paused, buffering, endedCurrent playback state
data-upgradedPresentComponent has initialized
data-fullscreenPresentThis player (not just any element on the page) is fullscreen
captionsPresentCaptions are currently showing
controlsPresentOverlay controls are visible
mutedPresentAudio is muted
role, aria-label, aria-keyshortcuts, tabindexgroup, "Video player", key list, 0Make the host a named keyboard target; authored values are kept

Localization

Every control name and announcement is an English default that you can override with a data-label-* attribute on the host. Times and numbers use the locale of the closest [lang] (via Intl.DurationFormat, falling back to Intl.NumberFormat), so Arabic-Indic digits, for example, appear automatically.

AttributeDefault
data-label-playerVideo player
data-label-controlsVideo controls
data-label-play-videoPlay video
data-label-play / data-label-pausePlay / Pause
data-label-seekSeek
data-label-skip-back / data-label-skip-forwardSkip back 10 seconds / Skip forward 10 seconds
data-label-muteMute
data-label-volumeVolume
data-label-speedPlayback speed {rate}
data-label-captionsCaptions
data-label-fullscreen / data-label-exit-fullscreenFullscreen / Exit fullscreen
data-label-playing, -paused, -ended, -bufferingStatus announcements
data-label-time-of{current} of {duration}

The controls bar is always laid out left-to-right, also on right-to-left pages, because the timeline runs from the start to the end of the media like every platform player.

CSS Custom Properties

PropertyDefaultDescription
--video-player-accentvar(--color-primary)Play button, timeline fill, active states
--video-player-controls-text#fffControls text and icon color
--video-player-radiusvar(--radius-m)Player border radius
--video-player-bordernonePlayer border (off by default)
--video-player-shadownonePlayer box shadow (opt-in)
--video-player-controls-paddingvar(--size-xs) var(--size-s)Controls area padding
--video-player-overlay-bgoklch(0% 0 0 / 0.4)Center play button backdrop
--video-player-timeline-height4pxTimeline track height
--video-player-timeline-bufferoklch(100% 0 0 / 0.3)Buffer progress color

Video controls overlay the content, so defaults are semi-transparent dark with white text (unlike <audio-player> which uses surface/text tokens).

Shadow Parts

PartDescription
playerOuter player container (position: relative wrapper)
controlsControls overlay at bottom
play-overlayBig center play button
play-buttonPlay/pause button in controls row
timelineSeek range input
mute-buttonMute toggle (aria-pressed)
volumeVolume range input
time-displayCurrent time / duration display
speed-buttonPlayback speed cycle button
captions-buttonCaptions toggle button
fullscreen-buttonFullscreen toggle button

Events

EventDetail
video-player:play{ currentTime, src }
video-player:pause{ currentTime }
video-player:ended{ src }
video-player:track-change{ src, title }
video-player:fullscreen{ active: boolean }
video-player:speed{ rate: number }
video-player:captions{ active: boolean, label: string }
video-player:src-changed{ src, source: 'property' } (fired when the src property is set)

Properties

PropertyTypeDescription
srcStringGet/set the inner video source; setting loads it and fires video-player:src-changed
currentTimeNumberPlayback position in seconds

Keyboard Shortcuts

Shortcuts work while the player itself has focus (it is a tab stop). When focus is on one of its controls, that control keeps its own keys, and key chords with Ctrl, Cmd or Alt are never intercepted.

KeyAction
Space / KPlay / Pause
Left ArrowSeek back 10 seconds
Right ArrowSeek forward 10 seconds
Up ArrowVolume up 5%
Down ArrowVolume down 5%
MToggle mute
FToggle fullscreen
CToggle captions
EscapeExit fullscreen (browser default)

On the sliders

ControlKeys
Seek sliderLeft/Down back 5 seconds, Right/Up forward 5 seconds; Home, End, Page Up, Page Down as native
Volume sliderNative: arrows change volume in 5% steps

Progressive Enhancement

The <video> element lives in light DOM and is visible via <slot> (not hidden like <audio>). Before JS loads, native controls render with poster and captions. After the component upgrades, native controls are hidden and custom overlay chrome takes over. If the component is removed from the DOM, native controls are restored.

Track List Data Attributes

<li> elements in .track-list use data attributes for state:

AttributeSet byMeaning
data-video-activeComponent + authorCurrently loaded/playing track
data-video-playedComponentTrack has been played this session

Track <a> elements support optional attributes for per-track switching:

AttributeDescription
data-posterPoster image URL for this track
data-captionsCaptions VTT file URL for this track

Accessibility

  • The host is a focusable role="group" named "Video player", with aria-keyshortcuts listing its shortcuts
  • All controls use native <button> or <input type="range"> with aria-label; the controls bar is a labelled role="group"
  • Seek slider aria-valuetext reads "0:05 of 3:20"; the volume slider reads a percentage, e.g. "37%"
  • Mute and captions buttons use aria-pressed to reflect state
  • The big play button is only focusable while it is visible (idle and ended); otherwise it is inert
  • Auto-hide never hides the controls while focus is inside them
  • The speed button's name carries the current rate ("Playback speed 1.5x"); a change made with the button is announced once, politely
  • Hidden role="status" region announces "Playing", "Paused", "Ended", "Buffering"
  • Respects prefers-reduced-motion: no autoplay, no transitions, controls stay visible
  • Forced colours: progress and volume fills use system colours (Highlight), tracks are outlined
  • Falls back to fully accessible native <video> without JS
  • Captions rendered by native <video> and styled with the video::cue hooks

Fullscreen

Fullscreen is requested on the host element (not the <video>), so the custom shadow DOM controls remain visible in fullscreen mode. The <video> fills the host via CSS. Fullscreen state is tracked per player: only the player that is actually fullscreen sets data-fullscreen and fires video-player:fullscreen.

Related

  • <video> — Native video element (Layers 1-3)
  • <audio-player> — Audio equivalent with same architecture
  • <youtube-player> — YouTube embed with facade pattern (no <video> element)
  • <track> — Captions, subtitles, and chapter tracks
  • controls — The browser's built-in media controls
  • poster — The poster image; also set through data-poster
  • preload — How much media to download before play
↑