Video Player
Themed controls over a real video: chapters on the seek bar, a thumbnail while scrubbing, captions, speed, picture-in-picture and full screen.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
label | string | — | Names the player (its group and the big play button), such as the video's title. |
src | string | undefined | — | A single video file, played by the player's own <video>. Leave it out when you slot a <video>. |
poster | string | undefined | — | The image shown before the first frame, with src. |
chapters | VideoChapter[] | [] | Chapters as [{ "start": 0, "title": "Intro" }, …], sorted by start (seconds). Without it, a <track kind="chapters"> gives them. |
thumbnails | string | VideoThumbnailResolver | undefined | — | Thumbnails shown while scrubbing: the URL of a WebVTT file whose cues are images or sprite regions
(thumbs.jpg#xywh=0,0,160,90), or, as a property, a function of the time. |
rates | number[] | [0.5, 0.75, 1, 1.25, 1.5, 2] | The speeds the settings menu offers. |
Slots
| Name | Description |
|---|---|
(default) | The <video> element, with its sources and tracks. |
Events
| Name | Type | Description |
|---|---|---|
chapter-change | CustomEvent | Playback entered another chapter. detail is { index, chapter }. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
player | The box holding the video, the overlays and the controls. |
controls | The bottom bar: the seek bar and the row of buttons. |
seek | The seek bar. |
preview | The time, chapter and thumbnail shown over the seek bar. |
big-play | The play button over the poster. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-video-player--width | length | 100% | The player's width; it keeps it as a flex item too. |
--c2-video-player--aspect-ratio | string | 16 / 9 | The player's shape before the video reports its own. |
--c2-video-player--background-color | color | #000000 | Behind the video (letterbox bars). |
--c2-video-player--color | color | #ffffff | Text and icons of the controls. |
--c2-video-player--border-radius | length | 8px | The player's corners (none in full screen). |
--c2-video-player__accent--color | color | rgb(2, 101, 220) | The played part of the seek bar and its handle. |
--c2-video-player__track--color | color | rgba(255, 255, 255, 0.28) | The seek bar not yet loaded. |
--c2-video-player__buffered--color | color | rgba(255, 255, 255, 0.5) | The loaded part of the seek bar. |
--c2-video-player__chapter--gap | length | 3px | The gap between chapter segments. |
--c2-video-player__controls--background | background | linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.35) 60%, transparent) | Behind the controls, so they read over a bright frame. |
--c2-video-player__control--size | length | 36px | The size of each control button. |
--c2-video-player__control__hover--background-color | color | rgba(255, 255, 255, 0.14) | A control button under the pointer. |
--c2-video-player__thumbnail--width | length | 160px | A whole-image thumbnail's width (a sprite region keeps its own size). |
--c2-video-player__tooltip--background-color | color | rgba(24, 24, 27, 0.9) | Behind the preview's time and chapter, and the menu. |
--c2-video-player__big-play--size | length | 68px | The play button over the poster. |
--c2-video-player__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | Focused controls. |
--c2-video-player__transition--duration | time | 200ms | The controls fading in and out. |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under video-player, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
player | Video player | — |
play | Play | — |
pause | Pause | — |
playVideo | Play {0} | {0} label |
mute | Mute | — |
unmute | Unmute | — |
volume | Volume | — |
seek | Seek | — |
timeOf | {0} of {1} | {0} time {1} duration |
timeOfInChapter | {0} of {1}, {2} | {0} time {1} duration {2} chapter |
captionsOn | Turn on captions: {0} | {0} track |
captionsOff | Turn off captions: {0} | {0} track |
settings | Settings | — |
speed | Speed | — |
rate | {0}× | {0} rate |
normalRate | Normal | — |
captions | Captions | — |
off | Off | — |
pip | Picture in picture | — |
exitPip | Exit picture in picture | — |
fullscreen | Full screen | — |
exitFullscreen | Exit full screen | — |
loading | Loading | — |
error | The video can’t be played | — |
errorAborted | Loading was stopped. | — |
errorNetwork | A network error stopped the download. | — |
errorDecode | The video is damaged or in a format this browser can’t play. | — |
errorSource | The video was not found, or its format is not supported. | — |
retry | Try again | — |
speedChanged | Speed {0} | {0} rate |
captionsChanged | Captions: {0} | {0} track |