Knit UI
GitHub

Playback options

Quality, screen wake, background playback and buffering are props on <Video>, and can be changed later with controller.setPlaybackOptions(). Each one is gated by a capability and does nothing where the platform has no such control.

<Video
  source={stream}
  maxResolution={{ width: 1280, height: 720 }}
  keepAwake
  backgroundPlayback
  buffer={{ forwardDuration: 30 }}
/>
OptionDefaultCapability
maxResolutionnull (no cap)canLimitResolution: the largest picture an adaptive stream may pick.
keepAwaketruecanKeepAwake: keep the screen on while playing. On web this is the Screen Wake Lock.
backgroundPlaybackfalsecanPlayInBackground: needs backgroundPlayback in the config plugin.
bufferplatform defaultscanTuneBuffer: forwardDuration, minForPlayback, maxBytes, prioritizeTime, waitToMinimizeStalling.
audioMixingMode"auto"How the sound sits with other audio. Native only.

Players that share the one engine keep their own options: a cap set on one player does not carry over to the next.

Visualizing a video's audio

A video controller can be sampled like an audio one, so useAudioSpectrum (also exported from @knitui/media/video) works with either. An HLS stream on iOS and a cross-origin source without CORS on web cannot be read, and stay silent.

Playground

Loading playground…

true
Playground
<Video
  source="https://media.w3.org/2010/05/sintel/trailer.mp4"
  contentFit="contain"
  size="md"
  controls
  autoHide
  loop={false}
  muted={false}
  aspectRatio={1.7777777777777777}
/>

Examples

Basic

Loading example…

BasicSourceStorybook

Auto Play Muted

Loading example…

Auto Play MutedSourceStorybook

Content Fit Cover

Loading example…

Content Fit CoverSourceStorybook

Sizes

Control sizing across the shared kit scale — the chrome's buttons, icons, and scrubber all step together off the canonical controlMetrics/icon ladders (the same scale Button/ActionIcon use), not a media-local copy.

Loading example…

SizesSourceStorybook

Native Platform Controls

Loading example…

Native Platform ControlsSourceStorybook

Custom Control Bar

Compose a custom control bar from the exported parts.

Loading example…

Custom Control BarSourceStorybook

Captions

Loading example…

CaptionsSourceStorybook

Custom Styled Captions

Because captions ride the kit overlay (not the platform's built-in subtitle renderer), their typography is fully stylable via the captions / captionText style slots — font, size, color, weight, background.

Loading example…

Custom Styled CaptionsSourceStorybook

Keyboard Shortcuts

Keyboard shortcuts (focus the player first): Space/k play·pause, ←/→ seek, ↑/↓ volume, m mute, f fullscreen, p PiP, 0–9 jump, </> speed.

Loading example…

Keyboard ShortcutsSourceStorybook

Persistent Controls

Always-visible controls (no auto-hide).

Loading example…

Persistent ControlsSourceStorybook

Styles

Per-slot styles overrides (Pillar B).

Loading example…

StylesSourceStorybook

Swap Source

Two players sharing nothing but the contract — swap the source at runtime.

Loading example…

Swap SourceSourceStorybook

Two Players

Two players sharing ONE shared video engine (the default singleton). The single <video> teleports into whichever player you press play on; the other shows its poster and pauses. Returning to the first resumes from where you left off — and there is only ever ONE <video> element in the DOM.

Loading example…

Two PlayersSourceStorybook

Now Playing

Now-playing / lock-screen controls with a cover preview. nowPlaying folds the title/artist/artwork into the source metadata and flips expo-video's showNowPlayingNotification + staysActiveInBackground, so the OS shows a media notification with the artwork as the cover and playback keeps going in the background. Native-only — surfacing it on a device build also needs the expo-video config plugin's supportsBackgroundPlayback: true. (No-op on web; the story still renders a normal player there.)

Loading example…

Now PlayingSourceStorybook

Props

PropTypeDefaultDescription
source requiredstring | number | VideoSourceObject | nullhttps://media.w3.org/2010/05/sintel/trailer.mp4The media to play.
allowsPictureInPictureboolean | undefined—Allow Picture-in-Picture. Default `true`.
artiststring | undefined—Now-playing artist / secondary text under the title.
artworkstring | undefined—Now-playing artwork (cover) image URL.
aspectRationumber | undefined—Fixed aspect ratio for the frame (e.g. `16 / 9`).
audioMixingModeVideoAudioMixingMode | undefined—How this video's sound sits with other audio, from this app or another: `"auto"` (the platform default: take over), `"mixWithOthers"`, `"duckOthers"` or `"doNotMix"`. `<MediaProvider exclusive={false}>` sets `"mixWithOthers"` for you. Native only.
autoHidenumber | boolean | undefinedtrueAuto-hide the chrome during playback. `true` uses the default delay, `false` keeps it always visible, a number sets the delay in ms.
autoPlayboolean | undefined—Begin playback as soon as the source is ready.
backgroundPlaybackboolean | undefined—Keep playing when the app goes to the background. Default `false`. Needs `backgroundPlayback` in the config plugin. (`canPlayInBackground`)
bufferVideoBufferOptions | null | undefined—Buffer tuning; `null` goes back to the player's own buffering. (`canTuneBuffer`)
contentFitVideoContentFit | undefined
contain · cover · fill
containHow the frame is scaled in the container. Default `'contain'`.
controlsReactNodetrueThe control chrome. `true` (default) renders the built-in control bar; `false` renders no chrome; a node renders custom chrome inside the context (compose `Video.*` parts).
controlsOffsetnumber | Space | undefined—Inset of the control bar from the frame edges.
doubleClickToFullscreenboolean | undefined—Web: double-click/tap the video to toggle fullscreen. Default `true`.
getController((controller: VideoController) => void) | undefined——
heightnumber | true | "xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl" | `${string} ${string}` | `${string}:${string}` | "auto" | "inherit" | "unset" | "max-content" | "min-content" | `${number}px` | (`${string}%` & {}) | `${number}rem` | Unionab…——
idstring | undefined—Stable identity for the shared-engine registry. Defaults to a generated id (each `<Video>` is its own player); pass an explicit `id` to make two mounts address the SAME shared-engine slot.
keepAwakeboolean | undefined—Keep the screen on while this video plays. Default `true`. (`canKeepAwake`)
keyboardboolean | undefined—Enable keyboard shortcuts (space, arrows, m, f, …). Default `true`.
labelstring | undefined—Accessible label for the player region. Default `"Video player"`.
loopboolean | undefinedfalseReplay automatically on end.
maxResolutionVideoTrackSize | null | undefined—The largest picture an adaptive stream may select, e.g. `{ width: 1280, height: 720 }` to save data. `null` removes the cap. (`capabilities.canLimitResolution`)
mutedboolean | undefinedfalseStart muted (required by browsers for unattended autoplay).
nativeControlsboolean | undefined—Use the platform's own native controls instead of the kit chrome.
nowPlayingboolean | VideoMetadata | undefined—Enable the OS now-playing notification + lock-screen controls (native; no-op on web). `true` derives the displayed metadata from `title`/`artist`/`artwork`; an object supplies it explicitly. Surfacing it on a device build also requires the `expo-video` config plugin's `supportsBackgroundPlayback: true`.
onEnded(() => void) | undefined——
onError((error: VideoError) => void) | undefined——
onPlayingChange((playing: boolean) => void) | undefined——
onReady(() => void) | undefined—Fired once the player first becomes ready to play.
onStatusChange((status: VideoStatus, error: VideoError | null) => void) | undefined——
onTimeUpdate((currentTime: number) => void) | undefined——
playbackRatenumber | undefined—Initial playback rate.
posterstring | undefined—Poster image shown before playback (placeholder while the player is idle).
preloadboolean | undefined—Fetch the start of the source as soon as the player mounts, so the first play starts without a wait. Off by default: it spends the visitor's data on media they may never play, so turn it on for the one or two players that will be.
showBigPlayButtonboolean | undefined—Show the centered big play button while paused. Default `true`.
size system"xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl" | undefined
xxs · xs · sm · md · lg · xl · xxl
mdControl sizing scale. Default `'md'`.
styles systemSlotStyles<VideoStyles> | undefined—Per-slot style overrides.
testIDstring | undefined——
textTracksVideoTextTrack[] | undefined—External (sidecar) caption files. The controller fetches, parses, and renders them with the kit's own overlay on every platform.
timeUpdateIntervalnumber | undefined—Seconds the controller waits between `timeUpdate` emissions (native).
titlestring | undefined—Now-playing title (used for the OS lock-screen / now-playing notification).
updateIntervalnumber | undefined—Status / `timeUpdate` interval, ms (native). The unified name.
volumenumber | undefined—Initial volume, 0..1.
widthnumber | true | "xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl" | `${string} ${string}` | `${string}:${string}` | "auto" | "inherit" | "unset" | "max-content" | "min-content" | `${number}px` | (`${string}%` & {}) | `${number}rem` | Unionab…—Frame style props (width/height/borderRadius…).

Style slots

Every part of Video can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotTargets
bigPlay—
buffering—
captionsThe caption cue bubble (background, radius, padding, position offset).
captionTextThe caption cue text (fontFamily, fontSize, color, fontWeight, …).
controlBar—
root—
scrim—
surface—

Edit this page on GitHub