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
OptionalSourceClass: new (playing: IPlaying, params: Params) => SourceOptional Source logic to use, by default it uses HTTPAdaptiveSource unless Connect.Params.endPoint begin with ws:// see Player.start
Gets the audio byte rate in bytes per second, include only the audio payload data.
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
Returns true When player is buffering data on start or after a stall. Become false when reach bufferLimitMiddle (in this case bufferState == BufferState.OK)
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
The CMCD session ID
Set the CMCD session ID, if undefined reset to empty string
Gets the current playback time in seconds
Gets the data byte rate in bytes per second, include messages and other non-media payload data like container overhead.
Index of the data track being received, can be undefined if the player is not playing
Select a or multiple data track to the index provided, must be set after starting.
When set to undefined it selects all data tracks available.
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
Returns stream metadata
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 including audio, video and data channels
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.
Returns true when player has started (after Player.onStart event)
Gets the playback start time in seconds
Indicates whether tracks can be combined in the same request, by default tracks are combinable to optimize the number of requests
Set whether tracks can be combined in the same request, by default tracks are combinable to optimize the number of requests
Returns true if manual track selection is supported by the source implementation, can also returns undefined if player is not running
Gets the video byte rate in bytes per second, include only the video payload data.
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.
Calculate and return current player statistics as a PlayerStats object
Moves the playback head as close as possible to the live point, while respecting the configured bufferLimitLow and bufferLimitHigh buffer thresholds.
Optionalreason: 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
Optionaloptions: { signal?: AbortSignal }Optionalsignal?: 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
Optionaloptions: { signal?: AbortSignal }Optionalsignal?: AbortSignalOptional AbortSignal to stop this or multiple subscriptions in same time
Starts playing the stream
If a MediaKeys engine is already running, it means that the previous playback has not been properly released, so the player stops and reports a PlayerError error to avoid unexpected behavior.
Connection parameters Connect.Params
OptionalidleTimeout: 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.
Stops playback. If an error is provided, it is treated as an improper stop and propagated to onStop.
Optionalerror: PlayerErroroptional error describing why playback stopped improperly
Event fire when audio data are appended to media source, basically here to debug MSE ingestion
Event fire on audio skipping
Event fire when the buffer amount changes by at least BUFFER_CHANGE_STEP ms
Event fired when data is received in the stream
Fired when the URL and headers can be finalized before sending the request to the server.
the request URL to finalize or modify if needed
the request headers to adjust if needed
Event fired when MediaKeys state changes if contentProtection is found in the metadata
MediaKeys support can be disabled by setting no contentProtection in the player parameters
OptionalmediaKeysEngine: MediaKeysEngineThe MediaKeys engine instance when ready, undefined when released
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 fire on playback stall
Event fired when streaming starts
Event fired when streaming stops
Optionalerror: PlayerErrorerror description when playback stopped improperly
Fire on a track change
Event fire when video data are appended to media source, basically here to debug MSE ingestion
Event fire on video skipping
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