TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/CeeblueTV/wrts-client/llms.txt
Use this file to discover all available pages before exploring further.
Player class is the main entry point for WebRTS streaming. It manages the full playback lifecycle — buffering, track selection, adaptive bitrate, and live-edge synchronization — while exposing a set of events and properties that let you observe and control every aspect of playback. This guide walks through each area in detail.
Lifecycle Events
ThePlayer exposes event callbacks that fire at each key moment of the playback lifecycle. Override any of them before calling player.start() to respond to state changes.
onStart — playback has begun
onStart — playback has begun
Fires once streaming is fully initialized and the first frame is ready to play.
onStop(error?) — playback ended
onStop(error?) — playback ended
Fires when streaming stops, either cleanly or due to an error. When
error is defined, the stop was abnormal.onMetadata(metadata) — stream metadata available
onMetadata(metadata) — stream metadata available
Fires when stream metadata is first received. The optional return value allows you to specify the initial track selection. By default the player picks the middle-quality rendition.
onTrackChange(audioTrack, videoTrack, dataTrack) — active tracks changed
onTrackChange(audioTrack, videoTrack, dataTrack) — active tracks changed
Fires whenever the player switches to a different audio, video, or data track — either by ABR or by manual assignment.
onBufferState(oldState) — buffer state transitioned
onBufferState(oldState) — buffer state transitioned
Fires when the buffer crosses a threshold and transitions between
BufferState.LOW, BufferState.OK, and BufferState.HIGH. The previous state is passed as oldState.onStall() — playback stalled
onStall() — playback stalled
Fires when the video element pauses waiting for data (a buffer underrun). The player automatically recovers when enough data arrives.
onAudioSkipping(holeMs) / onVideoSkipping(holeMs) — frames skipped
onAudioSkipping(holeMs) / onVideoSkipping(holeMs) — frames skipped
Fires when a gap in audio or video is detected and skipped.
holeMs is the size of the skipped hole in milliseconds.Starting and Stopping
Start playback
Call An optional second argument
player.start() with a Connect.Params object. The endPoint is the WRTS index URL obtained from the Ceeblue API.idleTimeout controls how long the player waits for a connection or data before stopping with a 'Start timeout' or 'Data timeout' error. The default is approximately 14 seconds — slightly above the maximum GOP duration.Track Selection
The player exposesaudioTrack, videoTrack, and dataTrack for reading and writing the current track selection.
Reading the current tracks
Setting the initial track via onMetadata
UseonMetadata to influence the very first track before playback starts. Returning a Media.Tracks object sets the starting track while keeping MBR active — the adaptive algorithm can still switch away from it.
Switching tracks during playback
Assignplayer.videoTrack or player.audioTrack at any time after onStart. Setting a track disables MBR for that track type. Set the value back to undefined to re-enable adaptive selection.
Data track selection
ThedataTrack setter accepts a single index, an array of indices, a Set<number>, or undefined (which selects all available data tracks).
Checking track selectability
Pause and Resume
player.start() must have been called) before setting paused. Setting it on a stopped player throws: Start the player before to pause playback.
Seeking to the Live Edge
player.goLive() moves the playback head as close as possible to the live point by seeking to endTime − bufferLimitMiddle. This keeps the player within safe buffer bounds and avoids triggering an immediate stall.
reason string that appears in the log output for debugging:
Player State Properties
| Property | Type | Description |
|---|---|---|
player.running | boolean | true between start() and stop() |
player.started | boolean | true after onStart fires (source is live) |
player.buffering | boolean | true while filling the initial buffer or recovering from a stall |
player.bufferState | BufferState | Current buffer state: NONE, LOW, OK, or HIGH |
player.bufferAmount | number | Current buffer depth in milliseconds |
player.currentTime | number | Current playback position in seconds |
player.startTime | number | Start of the available buffer window in seconds |
player.endTime | number | End of the available buffer window (live point) in seconds |
player.latency | number | undefined | Estimated live latency in milliseconds |
player.playbackRate | number | Current <video>.playbackRate (1.0 = real-time) |
player.playbackSpeed | number | Effective measured playback speed |
player.passthroughCMAF | boolean | undefined | Read-only; true when the source is streaming CMAF in passthrough mode |
Statistics
player.computeStats() returns a PlayerStats snapshot you can use for monitoring dashboards or logging.