Player API Reference
The canonical player surface — methods, properties, and events — for a player returned by requestPlayer or createPlayer.
This page describes the player object itself: the PlayerAPI interface that requestPlayer and createPlayer return in @video/video-client-core. It does not cover creating a player or wiring it into a page — see View a Stream for setup and Customize your Player for building controls on top of this surface. The manifest event and polling cadence live on Player Events & Liveness.
Every method on the player is asynchronous and returns a Promise<void> that resolves when the change has been applied.
Playback control
| Method | Signature | Behavior |
|---|---|---|
play | play(): Promise<void> | Begins playback. Resolves once playback has started, or once the player has settled a refused attempt — see Refused playback. |
pause | pause(): Promise<void> | Pauses playback. |
mute | mute(): Promise<void> | Mutes audio output. |
unmute | unmute(): Promise<void> | Restores audio output. Also leaves the "forced" mute state — call it from a user gesture such as a click handler. |
setVolume | setVolume(value: number): Promise<void> | Sets the volume. value is a number from 0 to 1, not a percentage; setVolume(0.5) is half volume. |
setAutoPlay | setAutoPlay(value: boolean): Promise<void> | Turns autoplay on or off. |
setPoster | setPoster(value: string | "last-frame" | null): Promise<void> | Sets the poster to a URL, to the last decoded video frame, or clears it. |
setLoop | setLoop(enabled: boolean): Promise<void> | Loops VOD content when it reaches the end. Only meaningful for VOD. |
seek | seek(position: number): Promise<void> | Seeks VOD content to position seconds. Throws if position is outside [0, duration] or the duration is not yet known. For live streams use enableDvr instead. |
enableDvr | enableDvr(position: number): Promise<void> | Enters DVR mode at position seconds from the start of the buffered window. |
disableDvr | disableDvr(): Promise<void> | Leaves DVR mode and returns to the live edge. |
stop | stop(): Promise<void> | Stops playback and releases the current source. |
reset | reset(options?: PlayerOptionsIn): Promise<void> | Resets the player, optionally with replacement options. Clears lastError. |
[Symbol.asyncDispose] | await using player = … | Tears down drivers and releases every resource. Equivalent to stop() followed by disposal. |
Playback state
Each property is a read-only getter. Most have a matching event in the canonical event map.
| Property | Type | Meaning |
|---|---|---|
paused | boolean | Playback is currently paused. |
muted | boolean | "forced" | true when muted, false when not, and "forced" when the browser's autoplay policy imposed the mute — see Forced mute. |
volume | number | Current volume from 0 to 1. |
ready | boolean | The player is ready to begin playing video. |
mode | string | Current playback mode, typically "live", "dvr", or "vod". |
position | number | Current playback position in seconds. |
duration | number | Duration of the source in seconds. NaN for live streams. |
loop | boolean | VOD looping is on. |
poster | string | null | URL of the current poster, or null. |
blurred | boolean | The stream is blurred. Used for content protection and privacy features. |
hasAudio / hasVideo | boolean | The current source is delivering an audio or video track. Reported by the WebRTC driver and when playing a call participant, where a paused track counts as absent; other drivers do not populate them. See Audio-Only Streams. |
format | string | null | Identifier of the current driver's format, or null when unknown. |
manifestUrl | string | null | URL of the loaded manifest, or null for non-manifest sources. |
srcObject | MediaStream | null | The media stream backing playback, or null. |
call | CallAPI | null | The active WebRTC call when the WebRTC driver is in use, otherwise null. |
sourceMeta | Record<string, unknown> | Metadata extracted from the current source. |
lastError | Error | null | The most recent error the error event reported, kept even if no listener was attached at the time. Survives driver failover and manifest recovery, so pair it with playing or ready to tell a stale error from a live one. Cleared only by reset(). |
Forced mute
muted has three values, not two. "forced" means the browser refused to start unmuted playback and the player muted itself to get video on screen; the viewer did not ask for the mute. The player accepts unmute() from this state and returns to unmuted, but the browser policy that caused the forced mute still applies, so call unmute() from a user gesture — a tap-to-unmute control — rather than programmatically on load. The muted event carries the same distinction: its payload is true for an ordinary mute and "forced" for a policy-imposed one.
Refused playback
A browser can refuse play() — autoplay policy, low-power mode, or a background tab. The player handles a refusal in two stages and does not throw for a refusal it can recover from:
- If an unmuted
play()is rejected, the player mutes itself and retries. If the muted retry succeeds, playback starts andmutedreads"forced". - If the muted retry is also rejected (typically low-power mode), the player turns autoplay off and
play()resolves without starting playback.
There is no dedicated refusal event. A muted event with payload "forced" tells you the unmuted attempt was refused and the muted retry succeeded; a play() that resolves while paused is still true tells you both attempts were refused. During a driver's automatic startup, a refusal that ends in forced mute still counts as a running driver, so it does not trigger driver failover.
Quality
| Member | Type | Meaning |
|---|---|---|
qualities | string[] | The quality identifiers the current source offers, for example ["240p", "720p"]. These are the values setPreferredQuality accepts. |
preferredQuality | string | null | The identifier you asked for, or null while automatic selection is active. |
setPreferredQuality(name) | (name: string) => Promise<void> | Requests a quality by identifier. name must come from qualities; the driver may still downgrade if that rendition becomes unavailable. |
The qualities and preferredQuality events fire when either value changes. The identifiers are the rendition names the source publishes, not a fixed vocabulary of quality tiers.
Rendition switching
Whether setPreferredQuality interrupts playback depends on the active driver:
- The WebRTC driver switches renditions without pausing.
- Every other driver pauses playback, applies the new quality, and resumes if the player was playing. For VOD and recorded content the player also seeks back to the position it was at before the switch.
Treat a quality switch as something that can pause and resume playback, and let your controls follow the paused and playing events rather than assuming the transition is invisible.
To choose which drivers a player may use, and in what order, see Player Drivers.
Attaching to a video element
| Method | Signature | Behavior |
|---|---|---|
attachTo | attachTo(host: unknown, force?: boolean): Promise<void> | Attaches the player to an existing <video> element. Emits attached. |
detach | detach(force?: boolean): Promise<void> | Detaches from the current element. With force, pauses and stops the driver first. Emits detached. |
attached | boolean (getter) | A video element is currently attached. |
Pass the element reference itself to attachTo, not an id or a selector string. The player operates on the reference you hand it and never re-queries the document, so a <video> inside a shadow root works the same way as one in the light DOM.
Calling attachTo with the element the player is already attached to is a no-op. Calling it with a different element while attached does nothing unless force is true, in which case the player detaches from the old element first and then attaches to the new one.
Drivers
| Member | Type | Meaning |
|---|---|---|
drivers | string[] | Identifiers of the drivers configured for this player, in the order they are tried. |
nextDriver() | () => Promise<void> | Switches to the next driver in the list. |
switchDriver(driver) | (driver: string) => Promise<void> | Switches to a specific driver by identifier. |
The player emits noDrivers when every configured driver has been exhausted for the current media. The error event, by contrast, is informational: a driver reporting a failure does not by itself stop playback, and failover continues independently.
Fullscreen
| Member | Type | Meaning |
|---|---|---|
fullscreen | boolean (getter) | The player is in fullscreen mode. |
enterFullscreen() / exitFullscreen() | () => Promise<void> | Enter or leave fullscreen. |
fullScreenHandlers | { enter?: () => Promise<void>; exit?: () => Promise<void> } | Optional replacements for the default DOM requestFullscreen and exitFullscreen flow. |
Captions
| Member | Type | Meaning |
|---|---|---|
captionsEnabled | boolean (getter) | Captions are enabled for display. |
captionTracks | string[] (getter) | Available caption track ids. |
activeCaptionTrack | string | null (getter) | The selected track, or null. |
activeCaptionCues | CaptionCue[] (getter) | Cues active at the current position. Empty when captions are off. |
setCaptionsEnabled(enabled) | (enabled: boolean) => Promise<void> | Shows or hides captions. |
setActiveCaptionTrack(trackId) | (trackId: string | null) => Promise<void> | Selects a track. Throws if trackId is not in captionTracks. |
A CaptionCue carries id, startTime, endTime, and text (all required) plus an optional speaker parsed from WebVTT voice tags.
Events
The player is a typed event emitter: player.on(name, handler) subscribes and player.off(name, handler) unsubscribes. Two event maps exist, and it matters which one you read from.
- The canonical map,
PlayerAPIEvents, is the current surface and the one this page documents. - The compat map,
PlayerEvents, is the legacy surface. Every player still emits its events, but each is deprecated. It is not a second kind of player.
Canonical events
| Event | Payload | Fires when |
|---|---|---|
paused | void | Playback entered a paused state. |
playing | void | Playback started or resumed. |
canplay | void | The player has enough data to begin playback. |
ready | boolean | The player entered or left the ready state. |
dvr | void | DVR mode was activated. |
muted | true | "forced" | Audio was muted, by you or by the browser's autoplay policy. |
unmuted | void | Audio was unmuted. |
volume | number | Volume changed. Payload is the new level from 0 to 1. |
poster | string | null | The poster image changed. |
blurred | boolean | The blur state changed. |
attached | void | The player attached to a video element. |
detached | void | The player detached from its video element. |
format | string | null | The active format changed. |
hasAudio | boolean | Audio track availability changed. |
hasVideo | boolean | Video track availability changed. |
qualities | string[] | The set of available quality identifiers changed. |
preferredQuality | string | null | The preferred quality changed. |
drivers | string[] | The configured driver list changed. |
noDrivers | void | No configured driver can play the current media. |
error | Error | A playback error was reported. Informational, not terminal; the same error is stored on lastError. |
duration | number | The media duration was reported, in seconds. |
durationchange | number | The media duration changed, in seconds. |
position | number | The playback position advanced, in seconds. |
sourceMeta | Record<string, unknown> | Source metadata changed. |
sourceRotation | number | null | The rotation reported by the manifest changed. |
fullscreen | boolean | Fullscreen state changed. |
videoFirstPlay | void | The video element produced its first play event. |
cue | CaptionCue[] | The active caption cues changed. Payload is the cues active for the current track. |
Compat events
The compat map contains every canonical event above except the eight listed in the next section, plus these legacy names. Prefer the canonical name wherever one exists.
| Compat event | Payload | Canonical equivalent |
|---|---|---|
localVideoPaused | boolean | paused / playing |
localAudioMuted | boolean | muted / unmuted |
localAudioVolume | number | volume |
forcedMute | boolean | muted with payload "forced" |
hostElementAttached | { el: VideoElement } | attached |
timeupdate, progress | void | position |
driver | string | none — the active driver id changed |
driverFailover | boolean | none — the player failed over to a backup driver |
restartDriver | { timeout: number } | none |
implementation | void | none |
disposed | void | none — the player was disposed |
manifest | { state, code?, formats } | none — manifest players only; see Player Events & Liveness |
info | { code: string } | none |
playerAccessDenied | { message: string } | none |
peerAtCapacity | boolean | none |
consumerAudioEnabled, consumerVideoEnabled | boolean | none (WebRTC) |
noConsumerAudioAndVideo | boolean | none (WebRTC) |
videoCodecUnreceivable | { unreceivable: …[]; negotiated: …[] } | none (WebRTC) |
lowLatency | boolean | none (WebRTC) |
joinedCall | { call: CallAPI } | none (WebRTC) |
callEnded | void | none (WebRTC) |
currentPlayer | PlayerAPI | null | none |
isConnecting, isConnected | boolean | none (WebRTC signaling) |
websocketReconnect | void | none (WebRTC signaling) |
Canonical events the compat map omits
Eight canonical events have no entry in the compat map. If your listener types are derived from PlayerEvents, these names will not type-check, and code written against the compat surface never sees them:
canplay, cue, duration, fullscreen, position, ready, sourceMeta, sourceRotation
Subscribe to them through the canonical PlayerAPI type.
The manifest event
Players created from a manifest URL also emit manifest on every poll of the manifest document, with state set to online, offline, or forbidden. The payload shape, the polling intervals, and how to read liveness from it are documented once, on Player Events & Liveness; this page does not repeat them.
Rendering
The SDK renders no player chrome of its own. Attaching a player to a <video> element puts frames on screen and nothing else: every play, pause, volume, and quality control shown in the guides is authored by the integrator against the methods and events on this page. View a Stream shows both the React components and a vanilla JavaScript control set built this way, and Customize your Player walks through building your own.