Skip to content

Overview

The phase system is the complete ordered lifecycle of a player instance, a small closed set of stable states from idle to disposed. Phases do not enumerate event names; they capture coarse playback state.

phase()

Current fine-grained player phase.

Returns: PlayerPhase

PhaseEntered viaExits to
idleconstructorsetup via setup(config)
setupsetup(config) — config resolving, plugins registering, auth/streams/playlist mountingready when ready event fires
readyready event fires / load() completesloading via load(item)
loadingload(item) — backend pulling sourceready when loaded
startingplay() / load-play-next / load-playplaying on firstFrame
playingfirstFramebuffering, seeking, paused, ended, stopped
bufferingnetwork stall during playbackplaying when buffer refills
seekingseek operationplaying when seek completes
pausedpause()starting via play()
endednatural end of mediastarting via load / play / next
stoppedexplicit stop()starting via load / play
disposingdispose() from any phasedisposed
disposeddisposing completesterminal — no further transitions

Emits: phase with { from, to } on every transition.

TypeScript
player.on('phase', ({ from, to }) => {
console.log(`${from}${to}`);
});

if (player.phase() === 'playing') {
// safe to call transport methods
}

setupState()

Coarser than phase(), answers “is the player usable right now?”.

Phase(s)Return value
idleSetupState.NOT_SETUP
setupSetupState.SETTING_UP
disposing, disposedSetupState.DISPOSED
everything elseSetupState.READY

Returns: SetupState enum value

dispatching()

Names of all events currently being dispatched, innermost last. Empty when no event is dispatching.

Returns: ReadonlyArray<string>

Use this to detect “am I currently inside a beforePlay handler”:

TypeScript
player.on('beforeMutation', (evt) => {
const stack = player.dispatching();
if (stack.includes('beforeSeek')) {
// mutation called from inside a beforeSeek listener
}
});

pushDispatch(name) / popDispatch()

Internal helpers that maintain the dispatch stack. Called by runDispatchBefore around every before* event. Plugin authors building custom before-events call these to keep the stack accurate.

MethodReturns
pushDispatch(name: string)void
popDispatch()string | undefined

platform()

The active platform bundle. Returns browserPlatform even before setup() so early reads don’t need a null check.

Returns: IPlatform

See also