Animated Video Player
Animated Video Player
Real adaptive streaming with quiet controls, liquid surfaces, and cinematic expansion that keeps the video playing.
Dependencies
Interaction states
- Adaptive or fixed quality — Auto enables ABR. Manual requests retain buffered segments, so the active rendition may change later. Changing audio returns to Auto to avoid pinning an incompatible variant.
- Buffering and recovery — Media/engine events drive loading feedback. Shaka requests retry up to three times with backoff; HLS.js allows two additional fatal recovery attempts. Retry starts a fresh session.
- Browser limitations and troubleshooting — Check CORS on manifests, segments, captions and licenses, HTTPS, codecs, MSE/EME support, and autoplay policy. Diagnostics omit credentials. Iframe permission policy can block fullscreen/PiP/DRM; test natively.
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/video-playerFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Where it’s used
HLS and DASH
Use Shaka for adaptive HLS/DASH and protected streams. Select HLS.js explicitly for HLS. Native playback has fewer quality and diagnostic capabilities.
Compose a player
Set controls={false} and render VideoControls, VideoPlayButton, VideoSeekbar, VideoVolume, or VideoSettings as children. useVideoState selects stable fields; useVideoPlayer exposes normalized actions.
Protected playback
Pass source.drm.servers keyed by com.widevine.alpha, com.microsoft.playready, or com.apple.fps. Advanced Shaka configuration supports certificates and license headers. Use HTTPS, authorized assets, and runtime credentials. FairPlay requires device-specific packaging and certificates; the demo does not certify it.
What it handles
- One persistent video — GSAP interpolates the existing frame geometry into the top layer. No media reload occurs during cinematic expansion. Browser fullscreen is a separate API.
- Observable playback — Real bandwidth estimates, rendition bitrate, frame drops, buffer ranges and errors. N/A identifies unavailable measurements. Hidden diagnostics stop polling.
- Source installation — React 19, TypeScript, Tailwind CSS 4 and shadcn theme tokens are required. All helpers ship in this registry item; only the selected streaming engine loads at runtime in a splitting bundler.
Usage
Seven interactive examples cover formats, quality, diagnostics, engine comparison, motion and authorized DRM tests. Public media loads from its original host. DRM success is shown only after the protected stream plays. Browser fullscreen/PiP and commercial CDMs depend on device support. See the source registry documentation and docs/video-player.md for full integration and verification guidance.
import { VideoPlayer } from "@/components/video-player";
<VideoPlayer
src="https://storage.googleapis.com/shaka-demo-assets/sintel/dash.mpd"
type="dash"
title="Sintel"
muted
/>;Props
| Prop | Type | Description |
|---|---|---|
| src / source | string / VideoSource | URL or typed source including format, poster, and caller-provided Shaka DRM configuration. Explicit type is required for extensionless HLS/DASH URLs. Keep DRM configuration referentially stable. |
| type | hls | dash | mp4 | Optional format hint; otherwise detected from the URL extension. |
| engine | shaka | hls | native · shaka | Lazy-load one engine. HLS.js accepts HLS only and falls back to native HLS when MSE is unavailable. Engine changes reload media and restore time for the same URL. |
| poster / title | string | Poster URL and accessible video title. Source poster takes precedence. |
| autoPlay / muted / loop | boolean · false | Browser media preferences. Autoplay can be rejected by browser policy; user play remains available. |
| playing / onPlayingChange | boolean / (playing: boolean) => void | Optional controlled playback intent and actual media-event callback. Omit playing for local control. |
| controls | boolean · true | Show the default control composition. Set false and compose exported controls or use onReady for a custom interface. |
| enableGooey | boolean · true | SVG filtering applies only to decorative surfaces. False uses a static, unfiltered fallback. |
| enableAnimations / reducedMotion | boolean · true / boolean · false | GSAP motion toggle and reduced-motion preview. OS reduced-motion settings always take precedence; changes settle active motion. |
| enableDiagnostics | boolean · false | Lazy-load genuine engine/browser metrics and a bounded event timeline. Polls at 1Hz only while the panel is visible; copy exports sanitized JSON. |
| enablePictureInPicture / enableFullscreen | boolean · true | Enable PiP and fullscreen controls. The main fullscreen button animates viewport expansion; Settings offers browser fullscreen where supported. Unavailable browser actions are disabled and failed requests are announced. |
| onReady | (player: VideoPlayerHandle) => void | Receives normalized play, pause, seek, quality, audio, captions, volume, speed, and retry actions. |
| onError | (error: PlayerError) => void | Sanitized error code/category with fatal and retryable flags. Raw URLs, DRM payloads, and tokens are omitted. |
| className / style / children | string / CSSProperties / ReactNode | Wrapper customization and composable overlay content. useVideoPlayer/useVideoState expose normalized controls and state. |
Accessibility & motion
Native labeled buttons and sliders, focus-preserving keyboard menus, scoped shortcuts, touch controls, cinematic focus containment and restoration, live reduced motion. On the focused frame: Space/K play, arrows seek/volume, M mute, F fullscreen, C captions. Shortcuts do not consume input fields or button keys.
pnpm dlx shadcn@4.21.5 add @cavemio/video-player