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
| Prop | Type | Default | Description |
|---|---|---|---|
source (required) | ViewerSource | The video: a URL, a File/Blob, or bytes. | |
aspectRatio | string | CSS aspect ratio of the frame. Default 16 / 9. | |
autoPlay | boolean | ||
className | string | ||
loop | boolean | ||
muted | boolean | Starts muted (needed for autoplay in most browsers). | |
poster | string | ||
title | string | Accessible name, also used in control labels. Default "Video". | |
tracks | readonly 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