API reference
Provider, hooks, component, error boundary, and the imperative MoviiePlayerHandle.
Everything below is exported from @moviie/player-react. The data layer
(MoviieClient, playback types, typed errors, telemetry) is re-exported from
@moviie/player-sdk, and the contract constants come from @moviie/player-types:
this package never re-declares the contract.
<MoviieProvider>
Place at the root of the subtree that renders players. Provides the Moviie client and the viewer-token store.
| Prop | Type | Required | Description |
|---|---|---|---|
publishableKey | string | ✓ | Publishable key (mvi_pub_*). Secret keys are rejected by the playback API. |
clientInfo | Partial<MoviieClientInfo> | Optional client info for analytics. platform defaults to "web". | |
viewerTokenStore | ViewerTokenStore | Persisted viewer / telemetry token store. Defaults to in-memory (SSR-safe). | |
children | ReactNode | ✓ | Your app tree. |
useMoviieContext() reads the provider value from within the tree.
useMoviiePlayback(args)
Low-level hook that fetches playback metadata for an embed. useMoviiePlayer
wraps it; use this directly when you only need the data, not the component.
Arguments
| Field | Type | Description |
|---|---|---|
embedId | string | Required. UUID of the embed from the dashboard. |
dubbingLanguage | string | null | Request a specific dubbing language for the audio track. |
Return value
| Field | Type | Description |
|---|---|---|
data | MoviiePlaybackData | null | Full playback metadata. null while loading or on error. |
isLoading | boolean | true while the initial fetch is in flight. |
error | Error | null | Typed error when the fetch fails. See Error handling. |
retry | () => void | Re-triggers the playback fetch. |
useMoviiePlayer(options)
The main hook. Fetches playback metadata and returns it ready to spread onto
<MoviieVideo>. The Vidstack player instance is created by <MoviieVideo>
itself and exposed through the imperative handle (see below).
Options
| Option | Type | Default | Description |
|---|---|---|---|
embedId | string | — | Required. UUID of the embed. |
autoplay | boolean | dashboard | Override the embed's autoplay setting (within browser policy). |
pictureInPicture | boolean | dashboard | Override the embed's Picture-in-Picture setting. |
rememberPosition | boolean | dashboard | Override the embed's remember-position setting. |
dubbingLanguage | string | null | — | Initial dubbing language. |
Return value
| Field | Type | Description |
|---|---|---|
playback | MoviiePlaybackData | null | Full playback metadata. null while loading or on error. |
isLoading | boolean | true while the initial fetch is in flight. |
error | Error | null | Typed error when the fetch fails. |
retry | () => void | Re-triggers the playback fetch. |
options | UseMoviiePlayerOptions | The override options you passed. Spread onto <MoviieVideo> with the rest. |
const moviie = useMoviiePlayer({ embedId })
return <MoviieVideo {...moviie} aspectRatio={16 / 9} />useMoviieEvent(handle, event, listener)
Subscribe to a single contract event from React. Pass the handle you received
from <MoviieVideo>'s onReady (or a ref's .current); the subscription
re-binds when the handle changes and cleans up on unmount.
| Argument | Type | Description |
|---|---|---|
handle | MoviiePlayerHandle | null | undefined | The player handle. The hook is a no-op while it is null. |
event | PlayerAPIEvent | The contract event name (for example "ended"). |
listener | (detail: unknown) => void | Called when the event fires. |
useMoviieEvent(handle, "timeupdate", ({ currentTime }) => {
// ...
})For multiple events, use the onEvent prop on <MoviieVideo> instead.
<MoviieVideo>
The player component. Spread the return value of useMoviiePlayer onto it, plus
any presentation overrides.
Playback props
| Prop | Type | Description |
|---|---|---|
playback | MoviiePlaybackData | null | Playback metadata from useMoviiePlayer. null while loading or on error. |
isLoading | boolean | From useMoviiePlayer. Shows the loading surface. |
error | Error | null | From useMoviiePlayer. Renders the inline unavailable surface. |
retry | () => void | From useMoviiePlayer. Wired to the retry button on retryable errors. |
options | UseMoviiePlayerOptions | Override options forwarded from useMoviiePlayer. |
Presentation props
| Prop | Type | Default | Description |
|---|---|---|---|
aspectRatio | number | intrinsic | Width ÷ height ratio, e.g. 16 / 9. |
accentColor | string | embed branding | Accent color applied as --media-brand. |
poster | string | embed poster | Override the poster image URL. |
autoplay | boolean | dashboard | Override autoplay. |
branding | boolean | dashboard | Show or hide Moviie branding. |
controls | Partial<MoviiePlaybackControls> | dashboard | Per-control overrides on top of the API-delivered flags. |
className | string | — | Extra class name on the player root. |
See Configuration for the API-config-vs-prop rule
and the full controls flag list.
Callbacks
| Prop | Type | Description |
|---|---|---|
onReady | (handle: MoviiePlayerHandle) => void | Called once the player is ready, with the imperative handle. |
onEvent | (event: PlayerAPIEvent, detail: unknown) => void | Called for every contract event. Use useMoviieEvent for a single event. |
onError | (error: Error, info: ErrorInfo) => void | Forward unexpected render crashes to your reporter (for example Sentry.captureException). |
<MoviieVideo> also accepts a ref of type MoviiePlayerHandle.
<MoviieErrorBoundary>
React error boundary that catches crashes inside the player and keeps them from
taking down the host app. <MoviieVideo> already wraps itself in one; use this
directly to protect a larger tree or to supply a custom fallback.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Component tree to protect. |
fallback | ({ error, reset }) => ReactNode | minimal default | Custom fallback rendered on crash. Call reset() to clear the error and re-render. |
onError | (error: Error, info: ErrorInfo) => void | — | Called on each caught error. Wire your own reporter here. |
See Error handling.
MoviiePlayerHandle
The imperative control surface exposed through the <MoviieVideo> ref (or
onReady). It mirrors the window.Moviie JavaScript API and the
Expo player: the same methods, events, and properties.
One contract, three surfaces
Methods, events, and properties below are the same contract as the
JavaScript Player API. Rather than duplicate the full tables, see the shared
Reference for every signature, payload, and property
shape. The names are sourced from @moviie/player-types
(PLAYER_API_METHODS, PLAYER_API_PROPERTIES).
Methods
Grouped by purpose (full signatures in the Methods reference):
| Group | Methods |
|---|---|
| Playback | play, pause, togglePlay, stop |
| Seeking | seek, seekForward, seekBackward |
| Volume | mute, unmute, toggleMute, setVolume |
| Fullscreen | enterFullscreen, exitFullscreen, toggleFullscreen |
| Picture-in-Picture | enterPip, exitPip, togglePip |
| Playback rate | setPlaybackRate |
| AI surfaces | openSearch, closeSearch, openAiMenu, closeAiMenu, openQuiz, closeQuiz, openSummary, closeSummary, openEbook, closeEbook, openTutor, closeTutor, sendTutorMessage |
| Variants | selectVariant |
| Events | on, once, off |
| State | getState |
| Lifecycle | destroy |
handle.play()
handle.seek(30)
handle.openSummary()
const state = handle.getState() // PlayerState (contract shape)Events
Subscribe with useMoviieEvent(handle, event, listener), the onEvent prop, or
handle.on(event, listener). The full event set and payloads are in the
Events reference: lifecycle (ready, play, pause,
ended, timeupdate, seeking, seeked, volumechange, fullscreenenter,
fullscreenexit, pipenter, pipexit, qualitychange, error), CTAs
(ctashow, ctahide, ctaclick), and the AI surfaces (searchopen,
searchclose, aimenuopen, aimenuclose, quizopen, quizclose,
quizcomplete, summaryopen, summaryclose, ebookopen, ebookclose,
variantchange).
Properties
Read individual properties off the handle, or call getState() for a coherent
snapshot. The full list and types are in the
Properties reference: for example currentTime,
duration, paused, ended, volume, muted, fullscreen, pip,
playbackRate, availableQualities, plus the feature flags searchable,
quizzable, summarizable, ebookable, mindMappable, and version.
Contract constants
Re-exported from @moviie/player-types so you can reference contract names
without string literals:
import {
PLAYER_API_METHODS,
PLAYER_API_PROPERTIES,
PLAYER_API_VERSION,
} from "@moviie/player-react"Versioning
@moviie/player-react follows strict semver. It tracks the
PLAYER_API_VERSION contract: a breaking change to the contract (a contract
MAJOR bump in @moviie/player-types) ships as a corresponding MAJOR bump
here. The package never forks or extends the contract locally.