Constructs a new Player instance to render on the HTMLVideoElement passed in first argument, with an optionally Source to custom how getting the stream.
This doesn't start the playback, you must call Player.start method
HTMLVideoElement object to render the video
Optional
SourceClass: (new (playing, params) => Source)Optional Source logic to use, by default it uses HTTPAdaptiveSource unless Connect.Params.endPoint begin with ws:// see Player.start
// Default build
const player = new Player(video);
// Build with custom source implementation
const player = new Player(MySource);
Private
Optional
SourceOptional Source logic to use, by default it uses HTTPAdaptiveSource unless Connect.Params.endPoint begin with ws:// see Player.start
Private
_bufferPrivate
_bufferPrivate
_bufferPrivate
_bufferPrivate
_bufferingPrivate
_controllerPrivate
Optional
_maximumPrivate
Optional
_mediaPrivate
_metadataPrivate
_pausedPrivate
Optional
_playbackPrivate
Optional
_playbackPrivate
_playbackPrivate
Optional
_sourcePrivate
Optional
_timeoutPrivate
_videoStart a log
a Log object with the levels of log to call
Get the number of audio sample per second currently decoding
Index of the audio track, can be undefined if player is not playing
Sets the current audio track to the index provided, must be set after starting.
It disables MBR, set it to undefined
to reactivate MBR.
Gets the current playback buffer duration in milliseconds
Gets the high-buffer threshold for BufferState.HIGH in milliseconds
Set the high-buffer threshold for BufferState.HIGH in milliseconds
Gets the low-buffer threshold for BufferState.LOW in milliseconds
Set the low‐buffer threshold for BufferState.LOW in milliseconds
Gets the target (middle) buffer size in milliseconds. Latency control mechanisms will try to drive the buffer toward this value.
Represents the playback buffer state
Returns true When player is buffering data on start or after a stall. Become false when reach bufferLimitMiddle (in this case bufferState == BufferState.OK)
The CMCD session ID
Set the CMCD session ID, if undefined reset to empty string
Gets the current playback time in seconds
Gets the playback end time in seconds
Gets an estimation of playback latency in milliseconds, Computed as the difference between the estimated live time and the current playback time.
Get maximum resolution that the MBR algo can reach, undefined means no limit. Defaults to the value of Media.screenResolution
Set maximum resolution that the MBR algo can reach, undefined means no limit. Defaults to the value of Media.screenResolution
Source is CMAF and passthrough it to MSE, it's a debugging mode activable when you set Connect.Params.mediaExt to 'cmaf'
Returns true if player is paused
Enable or disable player's pause
Gets the current playback rate. A value of 1.0 represents real-time playback.
Gets the effective playback speed. A value of 1.0 represents real-time playback.
Gets the current receive byte rate
Gets whether playback is reliable
By default is false
while playback is in an unreliable mode with frame skipping enabled,
otherwise can returns true
when configured to not tolerate any frame loss
Sets whether playback should be treated as reliable.
When false
, playback operates in an unreliable mode with frame skipping enabled;
when true
, frame skipping is not tolerated and reliable mode is enforced.
Returns true when player is running (between a Player.start and a Player.stop)
Gets an AbortSignal useful for subscribing to playback stop events.
Gets the playback start time in seconds
Returns true when player has started (after Player.onStart event)
Returns true if manual track selection is supported by the source implementation, can also returns undefined if player is not running
Get the number of video frame per second currently decoding
Index of the video track, can be undefined if player is not playing
Sets the current video track to the index provided, must be set after starting.
It disables MBR, set it to undefined
to reactivate MBR.
Private
_newPrivate
_onPrivate
_onPrivate
_onPrivate
_setPrivate
_tryMoves the playback head as close as possible to the live point, while respecting the configured bufferLimitLow and bufferLimitHigh buffer thresholds.
Optional
reason: stringadd a log reason to display to explain this goLive call
Event unsubscription
Name of event without the 'on' prefix (ex: 'log' to 'onLog' event declared)
Event subscription
Name of event without the on
prefix (ex: log
to onLog
event declared)
Subscriber Function
Optional
options: { Optional
signal?: AbortSignalOptional AbortSignal
to stop this or multiple subscriptions in same time
Event subscription only one time, once time fired it's automatically unsubscribe
Name of event without the on
prefix (ex: log
to onLog
event declared)
Subscriber Function
Optional
options: { Optional
signal?: AbortSignalStarts playing the stream
Connection parameters Connect.Params
Optional
idleTimeout: numberidle timeout, default value is around 14s. It sets the timeout error in the absence of connection activity or data fetching, you can tune it to implement your reliable and consistent fallback mechanism.
player.start({
endPoint: <endPoint>
});
Stops playback. If an error is provided, it is treated as an improper stop and propagated to onStop.
Optional
error: PlayerErroroptional error describing why playback stopped improperly
Event fire when buffer state change
Event fired when metadata is available in the stream.
On the first occurrence, the optional return value allows specifying which track to use when starting the stream. By default, the middle-quality track is selected.
Note that this differs from using videoTrack or audioTrack, where a specific track is fixed, which disables any Adaptive Bitrate algorithm.
The metadata received from the stream.
Optional tracks to use for initializing the stream.
Event fired when streaming stops
Optional
error: PlayerErrorerror description when playback stopped improperly
Use Player to start playing a WebRTS stream.
You can implement and use a custom Source by passing it as the second argument in the constructor. If not provided, Player.start will attempt to determine the protocol from Connect.Params.endPoint to instantiate the corresponding Source.registerClass or fall back to the default HTTPAdaptiveSource.
You can initialize tracks selection by playing with onMetadata
Example