Skip to content

Overview

Player state methods expose the current health of the backend, network, and track selection as typed enum values. These are snapshot reads, so subscribe to the corresponding events for reactive updates.

bufferState()

Coarse buffer health derived from the active backend.

Backend stateReturn value
'loading'BufferState.LOADING
'seeking'BufferState.SEEKING
'stalled'BufferState.STALLED
anything else / no backendBufferState.IDLE

Returns: BufferState

TypeScript
import { BufferState } from '@nomercy-entertainment/nomercy-player-core';

player.on('phase', () => {
if (player.bufferState() === BufferState.STALLED) {
showBufferingOverlay();
}
});

networkState()

Current network reachability via the platform’s network monitor.

ConditionReturn value
No monitor registeredNetworkState.ONLINE
Monitor reports offlineNetworkState.OFFLINE
Monitor reports downlink < 1.5 MbpsNetworkState.SLOW
Online with acceptable bandwidthNetworkState.ONLINE

Returns: NetworkState

streamState()

Raw state string from the backend ('idle', 'loading', 'playing', etc.). Returns 'idle' when no backend is registered or the backend does not expose a state() method. Prefer bufferState() for typed enum access.

Returns: string

visibilityState()

Tab / page visibility. Returns VisibilityState.VISIBLE when no visibility monitor is configured (safe default for SSR / headless environments).

Returns: VisibilityState

qualityMode(target?)

Get or set the ABR quality selection mode.

Read: returns QualityState.AUTO or QualityState.MANUAL.

Write: qualityMode(level) switches to MANUAL mode and forwards to the backend. qualityMode('auto') switches back to AUTO.

Note: quality(idx) also updates _qualityState. Both paths keep the state in sync.

Events emitted: qualityState with { state: 'auto' | 'manual' }

audioTrackMode(idx?)

Get or set the audio track selection mode.

Read: returns AudioTrackState.DEFAULT or AudioTrackState.MANUAL.

Write: audioTrackMode(idx) selects the track at idx and marks the state as MANUAL.

Note: audioTrack(idx) also updates _audioTrackState. Both paths keep the state in sync.

Events emitted: audioTrackState with { state: 'default' | 'manual' }

See also