VideoPlayer
A video player built on the browser's own <video>.
View code
<VideoPlayer duration={703} chapters={chapters} transcript={transcript}>
<VideoPlayer.Screen label="Centering 3 kg" captionsLabel="English" chaptersLabel="Chapters">
<VideoPlayer.Source src="/lesson-2160.webm" type="video/webm" label="2160p" badge="4K" />
<VideoPlayer.Source src="/lesson-1080.webm" type="video/webm" label="1080p" badge="HD" />
<VideoPlayer.Source src="/lesson.mp4" type="video/mp4" />
<VideoPlayer.Controls label="Video controls">
<VideoPlayer.Progress label="Seek" />
<VideoPlayer.Play label="Play" pauseLabel="Pause" />
<VideoPlayer.Time />
<VideoPlayer.CaptionsToggle label="Subtitles/closed captions" />
<VideoPlayer.Settings label="Settings">
<VideoPlayer.SettingsToggle name="ambient" label="Ambient mode" checked />
<VideoPlayer.CaptionsMenu label="Subtitles/CC" offLabel="Off" backLabel="Back" />
<VideoPlayer.SettingsMenu name="sleep" label="Sleep timer" backLabel="Back">
<VideoPlayer.SettingsOption value="off" checked>Off</VideoPlayer.SettingsOption>
<VideoPlayer.SettingsOption value="15">15 minutes</VideoPlayer.SettingsOption>
<VideoPlayer.SettingsOption value="end">End of video</VideoPlayer.SettingsOption>
</VideoPlayer.SettingsMenu>
<VideoPlayer.SpeedMenu label="Playback speed" normalLabel="Normal" backLabel="Back" />
<VideoPlayer.QualityMenu label="Quality" backLabel="Back" />
</VideoPlayer.Settings>
<VideoPlayer.Theater label="Theater mode" />
<VideoPlayer.Fullscreen label="Full screen" />
</VideoPlayer.Controls>
</VideoPlayer.Screen>
<VideoPlayer.Scrubber />
<VideoPlayer.Caption meta="Lesson 7 · 11:43">Centering 3 kg</VideoPlayer.Caption>
<VideoPlayer.Side>
<VideoPlayer.Chapters label="Chapters" />
<VideoPlayer.Transcript label="Transcript" />
</VideoPlayer.Side>
</VideoPlayer>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { VideoPlayer } from "@sdxc/ui/video";A <figure> sharing one timeline with its parts; with no script its native controls play and
time links open the file there. Map VideoPlayerSync (@sdxc/ui/video/video-player) for
the bar. Theming: --ui-video-player- radius, progress-color, menu-bg, on-video, transcript-height.
Composition
The parts the component publishes, each a static property of the host.
VideoPlayerVideoPlayer.ScreenThe 16:9 screen: a native<video controls>holding its sources and the chapters and captions tracks written from the timeline, over a VideoPlayer.Frame when given, under a VideoPlayer.Controls bar that takes over from the native controls.VideoPlayer.SourceOne file the video may play, in preference order, exactly as a<source>inside<video>; the first one also gives every time link its address.VideoPlayer.FrameA drawn still under the video: it shows before playback and through any transparent part of the picture while it plays.VideoPlayer.ScrubberThe chapters as one bar of segments as long as each chapter, filled to the current moment, so the video's shape shows before it plays.VideoPlayer.CaptionThe video's title line: the title at the start, small print at the end, wrapping under each other on a narrow screen.VideoPlayer.SideThe second column: chapters, transcript and anything the page adds, such as a card for the next video, stacked in order.VideoPlayer.ChaptersThe chapters as links to their moments, each with its still when given; the chapter playing carriesaria-current.VideoPlayer.TranscriptThe transcript in a scroll region, each line behind a link to its moment; the line playing carriesaria-currentand the island keeps it in view.VideoPlayer.ControlsThe custom control bar along the bottom of the screen, renderedhiddenuntil the island swaps it for the native controls.VideoPlayer.ProgressThe seek slider: a native range over the video's length, so arrow keys, Home and End seek and assistive technology reads the time.VideoPlayer.PlayPlays and pauses; its accessible name says what a press does next.VideoPlayer.TimeThe time played and the video's length,1:12 / 11:43.VideoPlayer.CaptionsToggleTurns captions on and off: on shows the track last chosen in the captions menu, the first one at the start.VideoPlayer.SettingsThe settings gear and its menu: a Popover API surface the gear opens throughcommandfor, holding toggles and submenus in order.VideoPlayer.SettingsToggleA page-defined switch row: a real checkbox the page reads bynameand follows with an ordinarychangelistener, such as ambient mode or a voice boost.VideoPlayer.SettingsMenuA page-defined submenu: a row naming the current choice that opens a panel of VideoPlayer.SettingsOption radios under onename, such as a sleep timer.VideoPlayer.SettingsOptionOne choice of a VideoPlayer.SettingsMenu: a real radio under the menu's name, marked with a check when chosen.VideoPlayer.CaptionsMenuThe captions submenu: Off, then every captions and subtitles track the video holds.VideoPlayer.SpeedMenuThe playback speed submenu; a choice sets the video'splaybackRateand survives a quality change.VideoPlayer.QualityMenuThe quality submenu: one row per labelled VideoPlayer.Source, by itslabelandbadge; an unlabelled source is a format fallback and stays off the menu.VideoPlayer.TheaterTheater mode: setsdata-theateron the player, which drops the side column under the screen so the video takes the full width.VideoPlayer.FullscreenFull screen for the screen with its bar, so the controls stay.
Examples
<VideoPlayer duration={703} chapters={chapters} transcript={lines} tone="theater">
<VideoPlayer.Screen label="Centering 3 kg" captionsLabel="English" chaptersLabel="Chapters">
<VideoPlayer.Source src="/07.mp4" type="video/mp4" label="1080p" badge="HD" />
<VideoPlayer.Controls label="Video controls"><VideoPlayer.Progress label="Seek" /><VideoPlayer.Play label="Play" pauseLabel="Pause" /><VideoPlayer.Time /></VideoPlayer.Controls>
</VideoPlayer.Screen>
<VideoPlayer.Side><VideoPlayer.Transcript label="Transcript" /></VideoPlayer.Side>
</VideoPlayer>Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
duration | number | Yes | Length in seconds; it closes the last chapter and the last caption. |
chapters | readonly Chapter[] | No | Chapters in playing order. |
transcript | readonly Cue[] | No | Spoken lines in playing order. |
current | number | No | The moment the page renders as now, in seconds, before the island takes over. |
tone | "plain" | "theater" | No | Colour scheme of the player. @default "plain" |
children | RemixNode | Yes | The parts, in reading order; a VideoPlayer.Side becomes the second column. |
Also accepts everything in TagProps<"figure">.
VideoPlayer.Screen
| Prop | Type | Required | Description |
|---|---|---|---|
label | string | Yes | The video's accessible name. |
poster | string | No | Image shown before playback, as the native poster. |
language | string | No | Language of the chapters and captions tracks. @default "en" |
captionsLabel | string | Yes | The captions track's name in the player's menus, such as "English". |
chaptersLabel | string | Yes | The chapters track's name, such as "Chapters". |
children | RemixNode | Yes | VideoPlayer.Source elements in preference order, any extra <track>, an optional VideoPlayer.Frame and an optional VideoPlayer.Controls. |
Also accepts everything in Omit<TagProps<"div">, "children">.
VideoPlayer.Source
| Prop | Type | Required | Description |
|---|---|---|---|
src | string | Yes | The file's address; the first source's is where every time link points. |
type | string | No | Media type, such as video/webm, so the browser skips files it cannot play. |
label | string | No | The file's name in the quality menu, such as 1080p; the file name stands in when unset. |
badge | string | No | Short mark beside the label and on the settings gear, such as HD or 4K. |
Also accepts everything in Omit<TagProps<"source">, "children">.
VideoPlayer.Frame
VideoPlayer.Scrubber
VideoPlayer.Caption
| Prop | Type | Required | Description |
|---|---|---|---|
meta | RemixNode | No | Small print at the inline end, such as "Lesson 7 · 11:43". |
Also accepts everything in TagProps<"figcaption">.
VideoPlayer.Side
VideoPlayer.Chapters
| Prop | Type | Required | Description |
|---|---|---|---|
label | string | Yes | The visible label and the list's accessible name. |
Also accepts everything in Omit<TagProps<"nav">, "children">.
VideoPlayer.Transcript
| Prop | Type | Required | Description |
|---|---|---|---|
label | string | Yes | The visible label and the scroll region's accessible name. |
Also accepts everything in Omit<TagProps<"div">, "children">.
VideoPlayer.Controls
| Prop | Type | Required | Description |
|---|---|---|---|
label | string | Yes | The bar's accessible name, such as "Video controls". |
Also accepts everything in TagProps<"div">.
VideoPlayer.Progress
| Prop | Type | Required | Description |
|---|---|---|---|
label | string | Yes | The slider's accessible name, such as "Seek". |
Also accepts everything in Omit<
TagProps<"input">,
"type" | "min" | "max" | "value" | "children" | "role"
>.
VideoPlayer.Play
| Prop | Type | Required | Description |
|---|---|---|---|
pauseLabel | string | Yes | The name while the video plays; label is the name while it is paused. |
Also accepts everything in ButtonProps.
VideoPlayer.Time
VideoPlayer.CaptionsToggle
VideoPlayer.Settings
| Prop | Type | Required | Description |
|---|---|---|---|
id | string | No | The menu's id, which the gear's commandfor names. Defaults to a generated one. |
badge | string | false | No | Mark on the gear. Left out, it is the playing source's badge and follows the quality menu; false draws none. |
children | RemixNode | Yes | Rows of the menu, in order. |
Also accepts everything in ButtonProps.
VideoPlayer.SettingsToggle
| Prop | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The form name a change listener reads the switch by. |
label | RemixNode | Yes | The row's visible label. |
Also accepts everything in Omit<
TagProps<"input">,
"type" | "name" | "children"
>.
VideoPlayer.SettingsMenu
| Prop | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The radio group's form name, which a change listener reads the choice by. |
label | RemixNode | Yes | The row's visible label, repeated on the submenu's back row. |
backLabel | string | Yes | The back row's accessible prefix, such as "Back". |
children | RemixNode | Yes | VideoPlayer.SettingsOption elements; the one marked checked is chosen. |
Also accepts everything in Omit<TagProps<"div">, "children">.
VideoPlayer.SettingsOption
| Prop | Type | Required | Description |
|---|---|---|---|
value | string | Yes | The value a change listener reads from the menu's name once this is chosen. |
badge | RemixNode | No | A short mark after the label, such as 4K. |
children | RemixNode | Yes | The option's visible label, which its submenu's row repeats once chosen. |
Also accepts everything in Omit<
TagProps<"input">,
"type" | "name" | "children" | "value"
>.
VideoPlayer.CaptionsMenu
| Prop | Type | Required | Description |
|---|---|---|---|
offLabel | string | Yes | The option that hides every track, such as "Off". |
Also accepts everything in BuiltInMenuProps.
VideoPlayer.SpeedMenu
| Prop | Type | Required | Description |
|---|---|---|---|
rates | readonly number[] | No | Rates offered, in order. @default [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2] |
normalLabel | string | Yes | The name of rate 1, such as "Normal". |
Also accepts everything in BuiltInMenuProps.
VideoPlayer.QualityMenu
VideoPlayer.Theater
VideoPlayer.Fullscreen
Types
| Name | Values | What it decides |
|---|---|---|
Tone | "plain" | "theater" | plain follows the page's scheme; theater is a dark screening room in either. |