# Media

The MP4 player: anatomy, tokens, behavior, and the markup contract for every Mpalo surface.

HTML page: https://developer.mpalo.com/media
Markdown page: https://developer.mpalo.com/media.md

## Navigate sections

- [Player](media#player)
- [Anatomy](media#anatomy)
- [Tokens](media#tokens)
- [Behavior](media#behavior)
- [Markup contract](media#markup)

## Player

Scope: every Mpalo surface. One player carries MP4 playback. It has no window chrome, one radius, one soft shadow, and one ambient edge drawn from the picture.

**Rule.** The player is one true-black surface. The picture is the default state. The controls and metadata fade in on hover or keyboard focus and fade out when the pointer leaves. There are no traffic-light dots, no title bar, no divider rules, and no border. The player carries `--shadow-media` at half opacity and an ambient edge sampled from the current frame. `media.js` samples a two-pixel edge of the frame, averages it into one color, and sets a uniform shadow in that color. Size and intensity stay fixed, so the halo does not grow or dim from one part of the picture to another. Only the hue follows the frame. The color updates while the video plays and settles on the current frame when paused.

Your browser does not support the video element.

No transcript is available for this video.

### A dandelion, held for a moment

A dandelion study carries the player demo. The footage is a design reference, not a product walkthrough.

0:00  -0:00

## Anatomy

The player has six regions, each with one job, and nothing is added for decoration.

The stage is the picture and nothing else: true black, sixteen by nine, no border, with the frame filling the surface without cropping. The controls sit over it in two quiet groups. Picture in picture and expand occupy the top left, and the volume pill, its slider, and mute occupy the top right. These are the only controls above the picture, and they stay away from the center where the transport sits.

The center is the transport: rewind ten seconds, play or pause, forward ten seconds. Play is the largest target because it is the primary action. The bottom edge carries the title and description on the left and the transcript control on the right, with the sync control beside it only when the video has cues. That block sits directly on the picture, with no panel, no tint, and no divider. A single timeline runs beneath it: current time, the progress range, and remaining time on one line.

The transcript is a caption over the picture, not a panel below it. It rests at the bottom center when the player is not hovered or focused, and moves to the top center between the volume bar and the expand control when the player is hovered or keyboard-focused. When there are no cues it says so, rather than disappearing. The player is one surface, and the tokens keep it that way: the stage takes `--media-stage-bg`; controls take `--media-control-bg` and its hover partner; the caption takes `--media-caption-bg`; and both ranges share one treatment, with `--text-1` filling the traveled portion, `--surface-4` holding the remaining track, and a 16px thumb at the system radius. There is no border and no second radius.

## Tokens

The player adds media tokens to the shared system. Each demonstration isolates one token, shows its value inside the surface it controls, and pairs it with the no-go that breaks it. A page must not restyle these values.

### Radius

8px--radius    Use 8px 8px corner   No-go 0px square corner

The same radius applies to the player, controls, volume pill, ranges, and caption. There is no second radius.

### Stage

#000--media-stage-bg    Use 16:9, true black no tint   No-go surface-3 tinted stage

The stage and the video background use true black. The picture is the surface; it never sits on a card, a tint, or a border.

### Controls

translucent--media-control-bg    Use     rest    hover    translucent black   No-go    opaque surface-4

Controls and their hover state use translucent fills over the picture. They sit on the image without becoming cards.

### Caption

translucent--media-caption-bg    Use  A dandelion, held for a moment  translucent black, text shadow   No-go   A dandelion, held for a moment  solid panel, no overlay

The transcript caption sits over the picture with the media text shadow, never in a panel below it.

### Timeline

16px--text-1 fill, --surface-4 track    Use       filled, track, 16px thumb   No-go    hairline, no thumb

Progress and volume share one treatment. The filled portion is `--text-1`, the remainder is `--surface-4`, and the thumb is 16px at the system radius.

### Shadows

20%--shadow-media    Use  20%, --shadow-media   No-go  40%, --shadow-overlay

The media shadow belongs to the player only. The ambient edge is a separate runtime layer, not a second decorative shadow.

The ambient edge is not a fixed color. `media.js` samples the two-pixel edge of the current frame, averages it into one color, and writes `--mpalo-ambient-rgb`. Size and strength stay fixed through `--mpalo-ambient-blur` 18px, `--mpalo-ambient-spread` 2px, and `--mpalo-ambient-opacity` 0.55.

**Do not add a third shadow.** The player carries `--shadow-media` and the frame-derived ambient edge. Those two are the complete light model. A full-strength `--shadow-overlay` makes the player read as a dialog, and a border makes it read as a window.

## Behavior

The player is keyboard operable, and its state changes are exposed through labels and ARIA attributes.

- With the player focused, Space or K plays and pauses. Left and Right seek five seconds. M mutes. F expands or collapses the player.
- The play button swaps between play and pause, and its accessible name changes with the state. The mute button does the same.
- The progress range exposes the current position as text, for example “1:20 of 3:40”. The volume range reports its value from 0 to 1, and the player starts at one quarter volume.
- The transcript button opens and closes the caption and keeps `aria-expanded` in sync. The caption sits at the bottom center when the player is not hovered or focused, and moves to the top center between the volume bar and the expand control while the player is hovered or keyboard-focused. When the video has no cues, it says that no transcript is available and the sync control stays hidden.
- When cues exist, the sync button toggles whether the caption follows the active cue and keeps `aria-pressed` in sync. The caption line carries the active cue text.
- Picture in picture is hidden when the browser does not support it. A failed play or load reports what happened and what to try next.
- Expand lifts the player over the page on a backdrop. Clicking the backdrop or pressing Escape closes it, and the video keeps playing.
- Reduced motion is respected. No part of the player animates position; the controls use a short opacity fade, and the ambient sampling stops when reduced motion is requested.

## Markup contract

The component is reused through data attributes, not ids.

`media.js` finds every `[data-mpalo-video]` element and wires the controls inside it. The required hooks are `data-video-element` on the video, `data-video-play` on the play button, `data-video-progress` on the seek range, and `data-video-current` and `data-video-remaining` on the time labels. The optional hooks are `data-video-mute`, `data-video-volume`, `data-video-expand`, `data-video-pip`, `data-video-transcript`, `data-video-transcript-panel`, `data-video-transcript-line`, `data-video-sync`, `data-video-cue`, and `data-video-status`. The transcript panel contains the caption line. It states that no transcript is available when there are no cues.

The source lives in `apps/dev-site/design-system/media.css` and `media.js`. The build writes both to `public/design-system/`. Change the source, never the generated copy.

**Enforcement.** Change `media.css` or `media.js`, rebuild the developer site, and test the player with a keyboard and a screen reader. Run `npm run check:design-rules` and `npm run check:design-runtime`. A page-level player override fails review.

## Related pages

- [Accessibility](accessibility.md)
- [Components](components.md)
- [Data](data.md)

## Authoritative integration reference

- [API quickstart](https://api.mpalo.com/get-started)
- [API reference](https://api.mpalo.com/landing)
