Video player
ProA video player complete with nothing set: its own controls, keys, touch gestures, captions and states over a file or a stream, drawn in the theme over any picture. Not an M3 component (@windmorph/react-pro).
import { VideoPlayer, VideoPlayerControl, VideoPlayerControlGroup, VideoPlayerVolume, VideoPlayerNotice, MediaSlider, useVideoPlayer } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
| Key | Action |
|---|---|
| Space or K | Plays or pauses; the mark says "Playing" or "Paused". |
| J or L | Goes back or forward 10 seconds. |
| Arrow Left or Arrow Right | Goes back or forward 5 seconds. |
| Arrow Up or Arrow Down | Turns the volume up or down 5%. |
| M | Mutes or unmutes. |
| F | Enters or leaves full screen. |
| C | Turns captions on or off, with captions. |
| 0 to 9 | Goes to that tenth of the video: 5 to its middle. |
| < or > | Slower or faster, through playbackRates. |
| Shift + N | Next, with onNext. |
| R or Shift + R | Turns the picture a quarter clockwise or back, with rotatable. |
| T | Theater, when it is offered. |
| Escape | Leaves full screen (the browser's own). |
- The keys work while focus is inside the player (WCAG 2.1.4), in either case, and never with Alt, Control or Command, which stay the browser's.
- Space is left to a focused button, link or field; on the scrubber and the volume it plays and pauses.
- A key pressed in the settings, a menu or a dialog opened from the player is theirs. The scrubber's and the volume's own keys (arrows, Page Up and Page Down, Home and End) never reach the player.
- Each button's tooltip shows its key, and the button carries
aria-keyshortcuts; aVideoPlayerControlwithshortcutshows and binds its own.
Screen reader
- Role
- A
groupwitharia-roledescription"Video player". Every control is a button; the scrubber ("Seek") and the volume ("Volume") are sliders. - Accessible name
- The player takes
aria-labeloraria-labelledby(one is required), the video's title. Each control has a name and a tooltip (labels). - States announced
- On and off controls (Captions, Autoplay, Theater) report
aria-pressedwith a name that doesn't change; the tooltip says the state. Play, the sound button and full screen change their name ("Pause", "Unmute", "Exit full screen"). The scrubber is read in words, the volume as "Volume 55%". Settings reportsaria-haspopup="dialog",aria-expandedand, while open,aria-controls.
- What a key or a gesture did is said politely, each time, the same words twice included ("Forward 10 seconds", "Volume 55%", "Captions on: English").
- A turn is said and marked on the picture ("Rotated 90°", "Upright") whether it came from R, the Rotate button or the settings' Rotate row.
- Failed and offline are said at once, in an alert region mounted with the player.
- "Resumed from…" is said in words ("Resumed from 12 minutes, 34 seconds").
- Captions are drawn by the player as plain text; their markup is never rendered.
Focus
- The picture's own button is out of the tab order: the bar's Play is the one keyboards reach.
- Hidden controls stay in the tab order; keyboard focus arriving shows them, and they stay while focus is among them.
- When Play in the middle, Replay, Try again or the resumed note goes while it holds focus, focus moves first to the bar's Play, without scrolling.
- Every control shows the two-tone on-media focus ring (light inside a dark edge, 3:1 over any picture) on keyboard focus only.
Touch target
- Bar buttons are 48px wide in a 40px container from a 30rem player; a narrower player has 32px buttons with 2px between them, above the 24px of WCAG 2.5.8.
- For a coarse pointer the scrubber's slot is taller, the volume slider and Rotate are left out.
- Nothing needs a drag or a double tap alone (WCAG 2.5.7): the scrubber and the volume take single presses and keys, and J and L skip.
Motion
- Under reduced motion the controls, the marks, the poster, the volume's opening and Rotate change at once; fades stay.
- An animated icon of yours passed through
iconsis toldreducedMotion. - A player with
inView="play"doesn't start by itself under reduced motion.
What you need to do
- Name the player with the video's title.
- Give captions for speech (
captions, WebVTT), named bylabelwhere the language alone isn't enough. - With
autoPlayorinView="play", the video starts muted where the browser insists; it can always be paused without turning the sound on. - Name a locked speed preset's mark (
playbackRatePresets) if it means something, and tell the person why the speed didn't change fromonPlaybackRatePresetPress. - Translate
labels, or set them once for the app with aLabelsProvider: the player says many words, from its role description to the marks its keys leave. - In forced-colours mode the containers, marks and notices are drawn on
Canvaswith aCanvasTextborder, and an on control has aHighlightground.