Components
Player chrome
The controls under the video. Presentational parts that take the playback state in and hand commands out.
import { PlayerChrome } from "@sideby/ui/player";
<PlayerChrome
playing={player.playing}
position={player.position}
duration={player.duration}
buffered={player.buffered}
onplay={() => player.play()}
onpause={() => player.pause()}
onseek={(seconds) => player.seek(seconds)}
bind:volume
bind:muted
/> The demos on this page run on SimulatedPlayer, a docs-only stand-in: a grey 16:9 stage and a clock that ticks while it plays. Press play, drag the scrubber, then switch to viewer mode and turn buffering on.
What it is
PlayerChrome is the bar under the video, built from the parts below. It is presentational: the playback state comes in as props (playing, position, duration, buffered, buffering) and the person’s commands go out as callbacks (onplay, onpause, onseek). It never touches a video element itself. Phases 3 and 4 connect it to the real players and to the room.
The orange run of the scrubber is the only accent in the bar, along with the play button. The time, the volume and the buffering line stay neutral.
Host and viewer
The host drives playback for the whole room; everyone else watches along. So the chrome has two modes:
- host shows play and pause, the time, the scrubber and the volume.
- viewer shows no play, pause or seek controls at all. A read-only progress bar replaces the scrubber, and a line says who is driving: “Maya is driving”, or “the host is driving” when there is no name. Volume and mute stay, because they belong to each viewer and are never sent to the room.
In viewer mode the callbacks never fire, because there is nothing to press. That keeps a viewer from issuing playback commands from the UI, which is the groundwork for the rule that viewers cannot control playback. The UI is not the authority, though: the engine still checks who sent a command and turns away anything a viewer sends.
Buffering
While buffering is true, a hatched strip and the word buffering sit above the bar. The word carries the meaning and the hatch is decoration, so it reads the same in forced colours and to a screen reader. The region is a polite role="status" that stays in the page, so the word is announced when it appears.
import { BufferingIndicator } from "@sideby/ui/player";
<BufferingIndicator buffering={player.buffering} /> Scrubber
The seek bar. The orange run is what has played, the grey run under it is what is buffered, and the thumb is where you are. Drag it and let go, click anywhere on the bar, or focus it and use the keys below. The line under the bar counts the seeks the scrubber has handed out: one per release, never one per pixel of a drag.
No seeks yet
import { Scrubber } from "@sideby/ui/player";
<Scrubber
position={player.position}
duration={player.duration}
buffered={player.buffered}
onseek={(seconds) => player.seek(seconds)}
/> The scrubber is presentational. It shows position and calls onseek with the seconds the person chose; whatever owns the video decides what a seek means. In a room, Phase 3 turns that call into a seek command for everyone.
While the pointer is down, the thumb follows the pointer rather than position, so a clock that keeps ticking does not pull it back mid-drag. Once the seek is committed, it follows position again.
Play and pause
One button that does whichever is next. It is the player’s primary action, so it is the one accent fill in the bar. Its label names what pressing it will do: Play while paused, Pause while playing.
import { PlayPause } from "@sideby/ui/player";
<PlayPause
playing={player.playing}
onplay={() => player.play()}
onpause={() => player.pause()}
/> Time
Position and duration as timecodes, in mono tabular numerals so the digits hold still as they tick. Under an hour it reads 12:04; from an hour up, 1:32:00. Until the duration is known it shows --:--. Screen readers hear the spoken form instead: “12 minutes 4 seconds of 1 hour 32 minutes”, or “12 minutes 4 seconds, duration unknown”.
import { TimeDisplay } from "@sideby/ui/player";
<TimeDisplay position={724} duration={5520} />
<!-- Before the duration is known -->
<TimeDisplay position={724} duration={NaN} /> The helpers behind it are exported too: formatTimecode(seconds), spokenDuration(seconds) and spokenPosition(position, duration).
Volume
A mute toggle and a volume slider. Volume belongs to each viewer: it never goes to the room, and turning it down here changes nothing for anyone else. The slider uses the neutral fill and speaks “60 percent”. On a touch screen the slider is hidden, because phones use their hardware buttons, and only the mute toggle stays.
import { VolumeControl } from "@sideby/ui/player";
<VolumeControl bind:volume bind:muted /> Bind volume (0 to 1) and muted to keep them, for example in local storage. Turning the volume up while muted unmutes, as every player does.
Accessibility
- The scrubber is a
role="slider"named Seek. Itsaria-valuetextis spoken time, such as “12 minutes 4 seconds of 1 hour 32 minutes”, so a screen reader never reads out a raw number of seconds. - On the scrubber, Left and Right arrows (and Up and Down) step 1 second. PageUp and PageDown step 10 seconds. Home jumps to the start and End to the end.
- Each drag commits one seek when it is released, and each key press commits one seek. Nothing is sent while dragging.
- When the duration is not known yet, the scrubber is disabled and its value reads “12 minutes 4 seconds, duration unknown”.
- Every icon-only control has a label that names its action: Play, Pause, Mute, Unmute. The volume slider is named Volume.
- In viewer mode the progress bar is a
role="progressbar"named Playback position, with the same spoken value. It is not focusable, because there is nothing to do with it. - Touch targets: on a coarse pointer (a phone or tablet), every player control grows to control-lg, 44px, and the scrubber bar is 44px tall, so they are easy to hit with a thumb. On a mouse they stay at their desktop size.
- The bar wraps onto a second line on narrow screens instead of scrolling sideways.
Copy
The built-in words are fixed and plain: Play, Pause, Mute, Unmute, Seek, Volume, buffering, and the driver line, such as Maya is driving, which uses the host’s display name as they set it. Anything with more personality, such as a toast saying your video is catching up, belongs to the product around the chrome, not inside it.