Skip to content
Alea0.1
Pro
  1. Alea
  2. Components
  3. Data display
  4. MediaPlayer

Data displayAlea Pro

MediaPlayer

Video and audio with controls in the Alea look: play, seek with a time readout, skip back and forward, volume, speed, captions, picture in picture and full screen, with the keys people already know.

import { MediaPlayer } from '@alea/pro';

Examples

Video with captions

Focus the player and use the keys (Space, the arrows, J and L, M, F, C), or the controls. Captions come from WebVTT files in English and Spanish.

8 s

Audio

kind="audio" is a compact bar with the title, an artwork and the same controls, for podcasts, voice notes and previews.

Alea tonesTwelve notes, nine seconds

Tokens

The design tokens this component reads, with their value in the current theme. Override any of them to restyle it.

Color

  • --alea-bg…
  • --alea-border…
  • --alea-focus…
  • --alea-surface-raised…
  • --alea-text…
  • --alea-text-muted…

Space

  • --alea-space-2…
  • --alea-space-3…
  • --alea-space-4…
  • --alea-space-6…

Radius

  • --alea-radius-lg…
  • --alea-radius-md…

Type

  • --alea-font-family-body…
  • --alea-font-size-md…
  • --alea-font-size-sm…
  • --alea-font-size-xs…
  • --alea-font-weight-medium…
  • --alea-font-weight-semibold…

Motion

  • --alea-motion-duration-base…
  • --alea-motion-ease-emphasized…

Other

  • --alea-media-backdrop…
  • --alea-media-scrim…
  • --alea-on-media…

Props

MediaPlayer props

Video and audio with controls in the Alea look: play, seek with a time readout, skip back and forward, volume, speed, captions, picture in picture and full screen. The usual keys work while it has focus (Space or K, arrows, J and L, M, F, C), and every control is a named button or slider.

PropTypeDefaultDescription
srcrequiredstring-The media file.
titlerequiredstring-The title: names the player and shows above audio.
autoPlayboolean-Plays muted from the start (browsers only allow muted autoplay). Off by default: don't autoplay with sound.
classNamestring-Extra class names.
kind"audio" | "video"'video'video (default) or audio (a compact bar, no picture).
loopboolean-Plays again at the end.
onEnded(() => void)-Called when it ends.
onTimeUpdate((seconds: number) => void)-Called with the current time as it plays.
overlayReactNode-Extra content over the video corner: a badge, a live dot.
posterstring-An image shown before video plays, or as artwork for audio.
rationumber16Width to height ratio for video. Default 16 / 9.
speedsnumber[]-The speeds offered. Default 0.5 to 2.
subtitlestring-A second line for audio: the artist, the show.
tracksMediaTrack[]-Captions and subtitles (WebVTT). Video needs captions to be accessible.

Specs

Generated from the source: the variants in the types, the states and tokens in the CSS, and the motion patterns that apply. The grids render the real component in both themes; the numbers are measured from the page.

Variants
kindaudiovideo
States
Keyboard focusFocus insideHoverHover (CSS)
Dark and light
Every color comes from theme tokens, so it follows data-theme (and presets like Graphite) on the page or any wrapper. Contrast is checked in both themes.
Styling hooks
.alea-player.alea-player-art.alea-player-media.alea-player-overlay.alea-player-big.alea-player-bar.alea-player-titles.alea-player-title.alea-player-subtitle.alea-player-seek.alea-player-controls.alea-player-time
Data attributes
data-kind=audiodata-kind=videodata-idledata-full

Accessibility

  • The player is a named region that takes focus; the usual keys work inside it: Space or K play and pause, the arrows seek and change the volume, J and L skip 10 seconds, M mutes, F goes full screen, C toggles captions.
  • Every control is a named button; the seek and volume sliders say the time ("1:23 of 4:56") and the level.
  • Captions come from WebVTT tracks, and their button says whether they will turn on or off.
  • Nothing autoplays with sound: autoPlay starts muted.
  • While video plays the controls fade, and any key, focus or pointer move brings them back.

Keyboard

KeyDoes
Space or KPlays or pauses
Left / Right arrowBack or forward 5 seconds
J / LBack or forward 10 seconds
Up / Down arrowVolume up or down
MMutes
FFull screen (video)
CCaptions on or off (video)
Home / EndStart or end

Do and don't

Do

  • Give every video captions; give audio a transcript next to it.
  • Use a poster image that shows what the video is about.
  • Keep autoplay for silent, decorative loops.

Don't

  • Don't autoplay with sound.
  • Don't hide the controls for good: people need to pause.

In Figma

MediaPlayer with Kind (Video, Audio) and the control bar states.

Tested with axe, keyboard and screen reader roles