VideoPlayer

Video with themed controls: scrubbing with the buffered range, volume, speed, captions, picture in picture and fullscreen.

Status: beta. Category: Viewers.

import { VideoPlayer } from '@glyphui/viewers/media'

Exports: VideoPlayer, videoPlayerStyles, formatTime.

Notes

  • No extra packages needed: it’s the browser’s video element with Glyph controls.
  • Keyboard: Space or K plays, ←/→ seek 5 seconds, J/L seek 10, ↑/↓ change volume, M mutes, C toggles captions, F goes fullscreen.
  • The position and volume sliders are real sliders for assistive technology, with spoken times.

VideoPlayer props

PropTypeDefaultDescription
source (required)ViewerSourceThe video: a URL, a File/Blob, or bytes.
aspectRatiostringCSS aspect ratio of the frame. Default 16 / 9.
autoPlayboolean
classNamestring
loopboolean
mutedbooleanStarts muted (needed for autoplay in most browsers).
posterstring
titlestringAccessible name, also used in control labels. Default "Video".
tracksreadonly MediaTrack[]Subtitle and caption files (WebVTT).

Example: With captions

Turn captions on from the control bar or press C.

import { VideoPlayer } from '@glyphui/viewers/media'
import { fixture } from '../../../lib/fixtures'

export default function Example() {
  return (
    <VideoPlayer
      source={fixture('clip.webm')}
      title="Product tour"
      tracks={[{ src: fixture('clip.vtt'), srcLang: 'en', label: 'English' }]}
      className="w-full max-w-2xl"
    />
  )
}

Live page: https://glyphui.xyz/components/video-player