Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Pro (paid add-on)

Video and audio players

Pro

VideoPlayer and AudioPlayer put brand-styled controls on the browser's own <video> and <audio>, so playback, formats and captions stay native, with a full set of keyboard shortcuts.

Part of Pro

This page documents part of @vjdesigns-pro/ui, the paid add-on package. Using it needs a Pro license and @vjdesigns/vjdesigns-ui 3.8.0 or later. Like the free package, it works in both modes, every brand, all 32 languages and right to left. Install it as described in Account forms.

Video

List several sources and the browser plays the first format it supports. tracks adds WebVTT captions, chosen from a captions menu; prerecorded video with speech needs them (WCAG 1.2.2). Size it with width, height or aspectRatio, plus fit and bordered. The controls offer play, seek, time, volume, captions, speed, picture in picture and full screen, and fade while playing.

tsx
import { AudioPlayer, VideoPlayer } from "@vjdesigns-pro/ui";

<VideoPlayer
  title="Defensive footwork drills"
  poster="/media/footwork.jpg"
  aspectRatio="16 / 9"
  sources={[
    { src: "/media/footwork.webm", type: "video/webm" },
    { src: "/media/footwork.mp4", type: "video/mp4" },
  ]}
  tracks={[{ src: "/media/footwork.en.vtt", srcLang: "en", label: "English", default: true }]}
/>

Audio

AudioPlayer has the same controls for audio (without captions or full screen), with an optional title, artist and cover artwork.

tsx
<AudioPlayer
  title="Episode 12: Building a youth program"
  artist="Courtside podcast"
  artwork={<img src="/media/podcast.jpg" alt="" />}
  sources={[{ src: "/media/episode-12.mp3", type: "audio/mpeg" }]}
/>

Keyboard

  • Space or K: play and pause.
  • Left and Right arrows: back or forward 5 seconds, following the reading direction. J and L: 10 seconds.
  • Up and Down arrows: volume. M: mute.
  • C: captions. F: full screen. < and >: speed.
  • Home and End: start and end. 0 to 9: jump through the video.

Accessible by default

  • Every control is a labeled button, slider or menu, and the controls come back when anything in the player gets focus.
  • Autoplay is always muted, and it's skipped for people who prefer reduced motion.
  • The players are named by their title, and cover art is hidden from assistive technology.
  • If no source can play, an alert says so. controls="native" switches to the browser's own controls.

Props

VideoPlayer

A video player with brand-styled controls on a native <video>: play, seek (with buffered range), time, volume, captions menu (WebVTT tracks), speed menu, picture in picture, and full screen. List several sources and the browser plays the first format it supports. Keyboard: Space or K play and pause, arrows seek 5s (following reading direction) and change volume, J / L seek 10s, M mutes, C toggles captions, F full screen, < and > change speed, Home / End, and 0 to 9 jump through the video.

VideoPlayer props
PropTypeDefault
tracks

Captions, subtitles, or chapters (WebVTT). Prerecorded video with speech needs captions (WCAG 1.2.2).

MediaTrack[]—
title

Accessible name of the player, e.g. the video's title.

string"Video player"
poster

Image shown before playback.

string—
width

Player width (number = px, or any CSS length).

number | string"100%"
height

Player height. Usually leave it out and set aspectRatio.

number | string—
aspectRatio

Box shape, e.g. "16 / 9" or "1".

stringthe video's own shape
fit

How the picture fills the box.

"contain""cover""contain"
bordered

Rounded frame with a border.

booleanfalse
controls

custom: the brand controls. native: the browser's own. none: no controls (decorative loops).

"custom""native""none""custom"
allowFullscreen

Offer full screen (when the browser supports it).

booleantrue
allowPip

Offer picture in picture (when the browser supports it).

booleantrue
className

Class name for the player root (the video element gets the rest of the props).

string—
style

Style for the player root.

CSSProperties—
sourcesRequired

Files to play, in order of preference.

MediaSource[]—
playbackRates

Playback speeds offered in the speed menu. [] hides it.

number[][0.5, 1, 1.5, 2]
autoPlay

Start playing when ready. Video autoplay is always muted, and skipped when the viewer prefers reduced motion.

booleanfalse
loop

Start from the beginning when it ends.

booleanfalse
muted

Start muted.

booleanfalse
preload

How much to load before play.

"none""metadata""auto""metadata"
onPlayingChange

Called when playback starts or stops.

(playing: boolean) => void—
labels

Overrides the built-in text (buttons, menus, error). Localize it here.

Partial<Record<"play" | "pause" | "mute" | "unmute" | "volume" | "seek" | "captions" | "speed" | "fullscreen" | "exitFullscreen" | "pip" | "exitPip" | "error", string>>—

Also accepts native <video> attributes, plus className, style and ref.

AudioPlayer

An audio player with the same brand controls as VideoPlayer (play, seek, time, volume, speed), plus optional title, artist, and cover art. Same keyboard shortcuts, minus full screen and captions.

AudioPlayer props
PropTypeDefault
title

Track or episode title. Also names the player.

ReactNode—
artist

Artist, show, or other secondary line.

ReactNode—
artwork

Cover art (an <img> or Image). Decorative: it's hidden from assistive tech.

ReactNode—
variant

card: a raised card. plain: just the controls.

"card""plain""card"
className

Class name for the player root.

string—
style

Style for the player root.

CSSProperties—
sourcesRequired

Files to play, in order of preference.

MediaSource[]—
playbackRates

Playback speeds offered in the speed menu. [] hides it.

number[][0.5, 1, 1.5, 2]
autoPlay

Start playing when ready. Video autoplay is always muted, and skipped when the viewer prefers reduced motion.

booleanfalse
loop

Start from the beginning when it ends.

booleanfalse
muted

Start muted.

booleanfalse
preload

How much to load before play.

"none""metadata""auto""metadata"
onPlayingChange

Called when playback starts or stops.

(playing: boolean) => void—
labels

Overrides the built-in text (buttons, menus, error). Localize it here.

Partial<Record<"play" | "pause" | "mute" | "unmute" | "volume" | "seek" | "captions" | "speed" | "fullscreen" | "exitFullscreen" | "pip" | "exitPip" | "error", string>>—

Also accepts native <audio> attributes, plus className, style and ref.

MediaSource

One media file. List several in order of preference; the browser plays the first it supports.

MediaSource props
PropTypeDefault
srcRequired

File URL.

string—
type

MIME type, with codecs when you know them, e.g. 'video/webm; codecs="av01"'. Lets the browser skip files it can't play.

string—

MediaTrack

A WebVTT text track: captions, subtitles, or chapters.

MediaTrack props
PropTypeDefault
srcRequired

.vtt file URL.

string—
kind"captions""subtitles""chapters""descriptions""captions"
srcLangRequired

Language code, e.g. "en".

string—
labelRequired

Name shown in the captions menu, e.g. "English".

string—
default

Turn this track on at first.

boolean—