Props Reference

Complete reference for all MP4EPlayer component props.

TypeScript Support
All props are fully typed. Import MP4EPlayerProps for the complete interface.

Source Props

Configure the video source. The player automatically extracts embedded metadata from the MP4 file - you typically only need to provide the src prop.

PropTypeDefaultDescription
srcstring-URL or path to the MP4 video file. Can be absolute URL, relative path, or blob URL. Metadata is automatically extracted from the MP4 atom. Required unless attachSource feeds the video.
streambooleanfalseThe video is a stream (HLS or DASH), not one MP4 file: nothing is read from its address and its length follows the video element. See Streams (HLS and DASH).
documentSrcstring-On a stream: the exported MP4E file whose interactivity belongs to it. The document, objects and in-file media are read from it while the picture comes from the stream. See Streams (HLS and DASH).
liveboolean | LiveOptionsfalseThe stream is live: the controls show a LIVE mark and how far behind the viewer is, and seeking stays inside what the stream lets the viewer replay. See Streams (HLS and DASH).
attachSource(video: HTMLVideoElement) => void | (() => void)-Feed the player's <video> with your own streaming library (hls.js, Shaka Player, dash.js). Return a function that detaches it. On a live stream both may be called more than once (a viewer who leaves live can watch from the programme's file and come back). Implies stream. See Streams (HLS and DASH).
metadataMP4EMetadata | null-The base metadata document. Neither this nor overrides is required — an ordinary MP4 with no embedded metadata still becomes fully interactive (the player generates a minimal base at runtime from the video's own dimensions and duration). When provided, this replaces the extracted/generated base; usually not needed, since the player auto-extracts metadata from the MP4 file. If the engine cannot load the document you pass, the player stays a plain video without interactivity or controls until you pass a document it can load.
runtimeFlagsMP4ERuntimeFlags-Optional runtime feature flags. Defaults to metadata.settings.runtimeFlags; this prop overrides metadata when provided.
objectGroupsObjectGroup[]-Object groups with display settings for controlling how objects are rendered and interact.
defaultDisplaySettingsObjectDisplaySettings-Default display settings applied to objects without group-specific settings.

Playback Props

Control video playback behavior.

PropTypeDefaultDescription
autoplaybooleanfalseStart playing as soon as the player is ready. The player starts it itself, so the video's rules and plugins (an ad's preroll included) see the play. Note: most browsers require muted=true for autoplay.
mutedbooleanfalseStart with audio muted. Required for autoplay in most browsers.
loopbooleanfalseRestart video from beginning when it ends.
initialTimenumber-Start playback from this time (in seconds), e.g. a link to a moment. Applied once per src, as soon as the video's interactivity has loaded. With @mp4e/player, pass it as initialTime in the MP4Engine config. Plugins see it as getVideoState().startTime, so they can skip start-of-video prompts.

Display Props

Control debug and canvas rendering options.

PropTypeDefaultDescription
showBboxesbooleanfalseShow bounding boxes/polygons on canvas.
showCanvasLabelsbooleantrueShow canvas labels on hover. Disable when using display plugins.
showObjectDisplaysbooleantrueShow object displays (tooltips, product cards) on hover/click.
interactivebooleantrueOpt OUT of the engine entirely when false — renders a plain, non-interactive <video> element with no WASM engine, no render loop, no overlays/controls/menu, and no metadata bootstrap (host-supplied or generated). An explicit escape hatch for a bare video, not a lightweight mode that can gain interactivity later without a full remount.
controlsbooleantrueShow built-in playback controls (play/pause, seek, volume, fullscreen).
loadingIndicatorbooleantrueShow a small centered spinner over the frame area while the video has no decoded frame yet. The player holds overlays back over that same window, so the video and its interactive layer appear together instead of plugins painting over a black frame. Controls stay visible throughout. The engine renders the indicator itself (via MP4EngineConfig.loadingIndicator), so vanilla @mp4e/player hosts get the same affordance without writing one. On a source that never decodes a frame and never errors, the indicator stays up until the viewer starts playback. Setting this to false only hides the spinner — it does not change when overlays are revealed. Read at init: toggling it on a mounted player takes effect when src or interactive next changes. The ring stops animating for viewers who ask for reduced motion.

Callback Props

Event handlers for player lifecycle and interactions.

PropTypeDefaultDescription
onEvent(event: string, data: any) => void-Single event channel for ALL engine events (playback, objects, overlays, scenes, variables, errors). See Events Reference for all event names.
onFrameChange(frame: number) => void-Called on each frame change. Used for Studio timeline sync (high-frequency).
onVideoDuration(duration: number) => void-Called when video duration becomes available.

Host Configuration Props

Configure host-level behavior including metadata overrides, sandbox policies, and content trust. These props control how the player integrates with your host application.

PropTypeDefaultDescription
overrideSchedule{ at, overrides }[]-Dated overrides for a live stream: each entry applies when the viewer's picture reaches its time on the broadcast clock, so timed content lands on the same picture for every viewer. Kept in sync on later renders. See Streams (HLS and DASH), "Timed content".
overridesRecord<string, any>-A replaceable injection layer deep-merged on top of metadata (or the generated base, when metadata is omitted) at runtime. Neither this nor metadata is required for an ordinary video. Re-rendering with a new value REPLACES the current override layer outright (not a merge queue); {}, null, or undefined clears it and restores the base. Changing this prop does not reconstruct the engine or reload src, and playback position, variable values, running timers, counters, and the current scene all carry through the swap for ids that still exist. See Overrides page.
configMP4EConfig-Host behavior configuration — sandbox rules, action gating, plugin security, disabled content. See Configuration page.
trustContentbooleanfalseExplicit opt-in to the trusted sandbox level: every plugin gets allow-same-origin. Plugins are isolated from the host page by default; set this only for self-hosted deployments.
initialStateStateSnapshot | null-The state you kept for this viewer and video, when you keep it yourself (config.persistence.store: 'host'): the snapshot onStateSave last gave you. Used only when its key is the video's key. Read when the player is created. With @mp4e/player, pass it as initialState in the MP4Engine config. See Configuration › Keeping State Between Visits.
onStateSave(snapshot: StateSnapshot) => void-Called with a new snapshot whenever the video saves its state and you keep it yourself (config.persistence.store: 'host'). Keep the latest one, for example on your server against the signed-in viewer, and pass it back as initialState next time. Not called when the viewer has asked to limit storage. With @mp4e/player, pass it as onStateSave in the MP4Engine config.
Related Pages
See Configuration for the full MP4EConfig reference, Overrides for deep-merge examples, and Viewer Preferences for the runtime viewer preference system.

Security & Gating Callbacks

Callbacks for approving or denying gated actions and network requests. These give the host application full control over what plugins and actions are allowed to do at runtime.

PropTypeDefaultDescription
onActionGate(action: any, resolve: (approved: boolean) => void) => void-Called when a gated action is triggered. Show approval UI, then call resolve(true) to allow or resolve(false) to deny. An action from inside an ad break carries interstitial: { breakId, advertiser, placement }. See Configuration page.
onActionComplete(actionType: string, data: any) => void-Called after an action finishes executing — including viewer play/pause via the player controls. The data object is the fully resolved action and carries an initiator ({type, id?, event?, via?}) describing what caused it: the viewer, a rule (with its id), a plugin, or your application. See Player Events › Event Provenance.
onNetworkGate(request: { pluginId: string; url: string; method: string; interstitial?: { breakId: string; advertiser: string | null; placement: string } }, resolve: (approved: boolean) => void) => void-Called when a plugin's mp4e.fetch targets a domain outside its allowed list (by default, the domains its manifest declares). Approve or deny based on URL/domain; without this callback such requests are denied. pluginId names the calling plugin frame — a service plugin's key, an overlay's plugin-<overlayId> — not the plugin definition. A request from a plugin inside an ad break carries interstitial (its break, advertiser and placement). See Configuration page.
onOpenUrlGate(request: { type: 'openUrl' | 'navigate'; url: string; target?: string; pluginId?: string; purpose: 'offer' | 'open'; interstitial?: { breakId: string; advertiser: string | null; placement: string } }, resolve: (approved: boolean) => void) => void-Asked before a URL leaves the player. Without it URLs open as they always do. purpose 'open' means it is opening now; 'offer' means a plugin is asking whether to show a button for it at all. See Configuration page.
onSecurityViolation(violation: { pluginId: string; blockedURI: string; violatedDirective: string }) => void-Called when a plugin triggers a Content Security Policy violation.
Action Gating
Action gating uses an intersection model — each layer restricts, never expands. See Configuration for how to define gated actions and timeout policies.

Performance Props

Optimize video loading and seeking performance. Blob caching downloads the full file in the background for instant seeking after the initial load. For how a video exported with streamed interactive data loads its object tracking, see Streamed Loading.

PropTypeDefaultDescription
enableBlobCachebooleanfalseDownload the full video file in the background, then swap to a blob URL for instant seeking with zero network round-trips. The download starts once the video element has decoded its first frame, so it never delays initial playback.
blobCacheMaxBytesnumber1610612736Maximum file size in bytes for blob caching (default ~1.5 GB). Files exceeding this are skipped.

Start loading the engine early

A page that knows a video is about to play (a TV app, a page that opens a video at once) can start loading the player engine before it renders a player. Every player on the page shares that one load, so the first one starts sooner. Once loaded, the engine also warms itself up: a short-lived background worker runs the engine's start-up steps once on a built-in sample, so the first video's engine starts with that code already prepared by the browser (on a TV, its document then loads in about half the time). The earlier you call it, the more of that is done before the first video opens. Calling it more than once does nothing; if the early load fails, the player loads the engine itself as usual and reports any error.

Preload the engine
import { MP4Engine } from '@mp4e/react' // or '@mp4e/player'

// At page load, before the player mounts
MP4Engine.preloadEngine()

Advanced Props

Low-level props for customizing the player engine, controls, and debugging behavior. Most applications will not need to change these from their defaults.

PropTypeDefaultDescription
pluginOverridesRecord<string, { pluginId: string; config?: Record<string, any> }>-Override the built-in UI plugins for controls, subtitles, or menu with your own plugin implementations.
nativeControlsbooleanfalseUse native browser video controls instead of MP4E's custom controls.
useWorkerbooleantrueRun the WASM engine in a Web Worker. Reduces main thread load but adds ~15-20ms latency. Set to false for frame-perfect polygon rendering.
debugViewModeDebugViewMode | DebugViewLayer[]'none'Draw tracking data over the video. Pass a list of layers to draw together, for example ['bboxes', 'polygons']: 'bboxes' (each object's bounding box), 'polygons' (its outline), 'amodal' (its outline including hidden parts), 'corners' (a surface's four corners), 'mesh' (the tracking mesh points), 'zones' (each replacement zone's geometry, exactly as drawn), 'matte' (the soft matte of each prepared object a zone uses, tinted) and 'plate' (each removal's clean plate, unmasked); [] draws nothing. A single value also works: 'none', any one layer, 'corners+polygon' or 'mesh+polygon' (the same as the two-layer lists). 'matte' and 'plate' need WebGL. @mp4e/react and @mp4e/player export the types DebugViewMode, DebugViewLayer and DebugViewSetting, the layer names as DEBUG_VIEW_LAYERS, and debugLayersOf, which returns the list of layers any value draws.

Example

Example using currently implemented props:

InteractiveVideo.tsx
1import { MP4EPlayer } from '@mp4e/react';
2import '@mp4e/react/styles.css';
3
4function InteractiveVideo() {
5 return (
6 <MP4EPlayer
7 // Source (required) - metadata is auto-extracted from the MP4 file
8 src="https://cdn.example.com/video.mp4"
9
10 // Object display settings (optional)
11 objectGroups={[
12 {
13 id: 'products',
14 objectIds: ['obj_1', 'obj_2'],
15 displaySettings: { /* ... */ }
16 }
17 ]}
18
19 // Debug options
20 showBboxes={false}
21 showCanvasLabels={false}
22
23 // Single event handler
24 onEvent={(event, data) => {
25 if (event === 'state:ready') console.log('Engine ready!');
26 if (event === 'metadata:loaded') console.log('Loaded:', data.schemaVersion);
27 if (event === 'scene:enter') console.log('Scene changed:', data);
28 }}
29 />
30 );
31}