Documentation 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.
IPlaying is the contract between Source implementations and the Player. Every Source receives an IPlaying instance in its constructor and in its play() method. Through this interface, transport implementations can read buffer thresholds and metrics to make adaptive decisions (e.g., aborting a slow request before the buffer empties), subscribe to playback lifecycle events, and call computeStats() to build CMCD telemetry payloads. IPlaying extends EventEmitter from @ceeblue/web-utils, so its event methods (onBufferState, onStall, etc.) are both directly overridable and emittable.
BufferState Enum
BufferState describes the current health of the MSE playback buffer and drives both the adaptive bitrate algorithm and the playback-rate controller.
| Value | Description |
|---|---|
NONE | No active playback state — player is stopped or still in the initial loading phase. |
LOW | Buffer is critically low; stream-recovery mechanisms (stall detection, segment skipping) are active. |
OK | Buffer is within the acceptable range between bufferLimitLow and bufferLimitHigh. Normal playback. |
HIGH | Buffer exceeds the target; live-sync adjustments (increased playbackRate, goLive seeks) are active. |
Events
These methods are implemented on thePlayer class (which implements IPlaying). Source subclasses receive the Player instance as their IPlaying, so they can react to these events by reading the interface properties or subscribing via playing.signal.
Because IPlaying extends EventEmitter, each on* method can also be subscribed to programmatically using the EventEmitter.on() API. The event name strings used with .on() are the method names without the on prefix:
| Method | EventEmitter name | Example |
|---|---|---|
onBufferState | 'BufferState' | playing.on('BufferState', handler, playing) |
onStall | 'Stall' | playing.on('Stall', handler, playing) |
Pass
playing as the third argument to playing.on() (the abort-signal owner) so the subscription is automatically removed when the player stops.onBufferState()
NONE, LOW, OK, and HIGH. Read playing.bufferState for the new state; oldState holds the previous value.
The buffer state before the transition.
onBufferChange()
bufferAmount changes by at least 50 ms (the internal BUFFER_CHANGE_STEP constant). The Player’s default implementation calls adjustPlaybackRate(). Sources may observe this event to react to buffer fluctuations without polling.
onStall()
waiting) and the buffer falls below bufferLimitLow. Indicates that the stream cannot feed the decoder fast enough.
onAudioSkipping()
Source base class when a gap in the audio timeline is detected and skipped during timestamp fixing.
Duration of the skipped audio hole in milliseconds.
onVideoSkipping()
Source base class when video frames are skipped to maintain audio/video synchronisation.
Duration of the skipped video region in milliseconds.
Properties
Abort Signal
An
AbortSignal that fires when Player.stop() is called. Use this inside play() to abort in-flight fetch calls and other async operations, ensuring resources are cleaned up automatically when playback ends.Reliability
false by default — playback operates in unreliable mode with frame skipping enabled for lowest latency. true when the player has been configured to not tolerate any frame loss (reliable mode).Buffer Metrics
Current buffer depth in milliseconds, computed as
(endTime - currentTime) * 1000. Use this to decide whether to abort a slow request before the buffer empties.Low-buffer threshold in milliseconds (default 150 ms). When
bufferAmount drops below this value, bufferState becomes LOW.Target (midpoint) buffer depth in milliseconds, automatically computed as the midpoint between
bufferLimitLow and bufferLimitHigh. The player drives bufferAmount toward this value when recovering from a stall or after goLive().High-buffer threshold in milliseconds (default 550 ms). When
bufferAmount exceeds this value, bufferState becomes HIGH.true while the player is accumulating data during the initial start or after a stall. Becomes false once bufferAmount reaches bufferLimitMiddle.Current
BufferState value: NONE, LOW, OK, or HIGH.Byte Rates
Total incoming byte rate in bytes per second, covering all channels (audio + video + overhead).
Audio payload byte rate in bytes per second.
Video payload byte rate in bytes per second.
Data / metadata payload byte rate in bytes per second.
Frame Rates
Video frames being decoded per second.
Audio frames being decoded per second.
Playback Rate
Current
video.playbackRate. 1.0 is real-time; values above 1.0 mean the player is catching up to the live edge; values below 1.0 mean it is slowing down to fill the buffer.Effective playback speed measured from elapsed
currentTime changes, expressed as a ratio (1.0 = real-time). Distinct from playbackRate because it reflects actual decoder throughput rather than the requested rate.MBR & Format Hints
Upper-bound resolution for the MBR algorithm. Defaults to
Media.screenResolution(), updated on window.resize. Sources use this to avoid requesting renditions the display cannot show.Debug flag.
true when the Player was started with mediaExt: 'cmaf', bypassing the internal demuxer and passing CMAF segments directly to MSE. Sources should avoid demuxing when this is true.When
true (default), audio and video may be requested in a single combined HTTP request. false forces separate requests per track. undefined when the player is not running.computeStats()
PlayerStats snapshot (from @ceeblue/web-utils) capturing the current state of the player. Source implementations call this to build CMCD telemetry payloads inside fetchMedia(). The snapshot includes buffer depth, latency, playback rate, per-track byte rates, frame rates, track IDs, and stall count.
Using IPlaying in a Custom Source
The most common use ofIPlaying inside a custom Source is reacting to buffer state changes to implement adaptive request management — for example, aborting a slow segment fetch when the buffer is critically low.
IPlaying extends EventEmitter from @ceeblue/web-utils. The on* event methods on the Player can also be subscribed to programmatically through the EventEmitter API, but overriding the method directly (as shown above) is the idiomatic pattern for Source implementations.