Actions

VideoPlayer

Native video element with its own controls for play, pause, replay, seeking, elapsed and total time, mute, and full screen.

import { VideoPlayer } from '@lostgradient/cinder';
mediavideo
01

Overview

Reference usage

Native video element with its own controls for play, pause, replay, seeking, elapsed and total time, mute, and full screen.

The seek slider runs the full width under the video, and the buttons wrap in a row beneath it: the filled play button, Back 5 seconds, the elapsed and total time (1:05 / 3:20, or 1:02:05 from an hour up) once the length is known, the playback speed menu, then the mute and full-screen toggles, with the actions snippet at the inline end. markers draw numbered buttons on the seek track, chapters list the sections under the controls, and currentTime binds the position in seconds, so a page can read it and seek by writing it. poster shows an image before playback; posterTime shows a frame of the video itself instead, so the first frame is not blank, without moving where Play starts: the frame is shown from the chosen second once the length is known, currentTime and the seek track keep their position, and the first press of Play begins at currentTime (0 by default). With both poster and posterTime set, poster wins and the player does not seek. The arrow keys move the slider five seconds and Page Up and Page Down a tenth of the video; Home and End go to the start and the end. Full screen takes the whole player, controls included, and its toggle shows only where the document may go full screen. The player shows no captions yet: pair spoken video with a transcript.

Usage

svelte
<script lang="ts">
  import { VideoPlayer } from '@lostgradient/cinder';
</script>

<VideoPlayer
  src="https://example.com/media/intro.mp4"
  label="Product introduction"
  poster="https://example.com/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/media/intro.jpg"
/>

Guidance

Use When

  • Playing a single video from an https, http, or blob URL with accessible controls.
  • Showing a poster image until the viewer starts playback.

Avoid When

  • You need streaming protocols, caption authoring, or playlists — wire those separately.
Live preview

Basic video player

02

When to use

Use when
  • Playing a single video from an https, http, or blob URL with accessible controls.
  • Showing a poster image until the viewer starts playback.
Avoid when
  • You need streaming protocols, caption authoring, or playlists — wire those separately.
03

Examples

Basic video player

Play, pause, and seek from the media controls. Only https, http, and blob sources load.

Unavailable source

A source whose scheme is not https, http, or blob never loads and renders the unavailable controls.

04

Props

Props for video-player
Name
Type
Default
Description
src required text Media source. Only https:, http:, and blob: URLs load; any other scheme renders the unavailable state.
label required text Accessible name for the player.
poster text Image shown before playback starts.
posterTime number Second of the video to show before playback starts, once its length is known, so the first frame is not blank. It moves only what is shown: currentTime, the seek track, and the first play still start from currentTime. Ignored when poster is set. A negative, NaN or infinite value is ignored too: the player does not seek. A value past the end of the video shows the last frame.
markers VideoPlayerMarker[] Moments drawn as buttons on the seek track once the length is known. Each seeks to its time; close markers overlap, and the tab order reaches them in ascending time.
chapters VideoPlayerChapter[] Sections listed as buttons under the controls, each named by its start time and title.
chaptersLabel text 'Chapters' Accessible name of the chapter group.
playbackRates number[] [0.5,1,1.5,2] Rates the playback speed menu offers.
currentTime bindable number 0 Playback position in seconds; bindable. Writing it seeks, clamped to the length, and a value written before the length is known is applied once it is.
actions snippet Content drawn last in the controls row, given the current position.