AbstractGet the number of audio frame per second currently decoding
Index of the manual audio selection, undefined indicates automatic mode and -1 disable manually the track
Index of the effective audio track, can be undefined on start and -1 means track disabled
Select a audio track to the index provided, or indicates automatic with undefined
True when source is closed
The CMCD session ID
Set the CMCD session ID, if undefined reset to empty string
Index of the manual data selection, undefined indicates all tracks
Index of the data track being received, can be undefined on start
Select a or multiple data track to the index provided.
When set to undefined it selects all data tracks available.
Get the total duration of audio skipped in milliseconds
Get the total duration of video skipped in milliseconds
Stream name, for example as+bc3f535f-37f3-458b-8171-b4c5e77a6137
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
Get the number of video sample per second currently decoding
Index of the manual video selection, undefined indicates automatic mode and -1 disable manually the track
Index of the effective video track, can be undefined on start and -1 means track disabled
Optionalerror: SourceErrorProtectedfetchFetches a resource in a compliant way by invoking finalizeRequest during preparation.
the URL to fetch
Optionalinit: RequestInitoptional fetch configuration
the fetched response
ProtectedfetchProtectedfetchFetches a resource and measures the RTT (round-trip time) in a compliant way by invoking finalizeRequest during preparation.
the URL to fetch
Optionalinit: RequestInitoptional fetch configuration
the fetched response (including RTT metadata)
ProtectedfinalizePrepares a request, exposing the user-interception onFinalizeRequest to modify it if needed.
URL to adjust if need
HTTP headers to tweak as desired
the finalized URL
ProtectedfixProtectedinitInitializes the tracks to be received.
This method must be called first to declare which tracks should be negotiated and received.
Audio / Video:
= 0 → Receive the specified track index.
Data:
Track selection configuration.
ProtectednewCreate a Reader usable to feed the Source and matching mediaExt Can throw an exception if no demuxer is found for the related media extension
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
Protected AbstractplayProtectedreadIngest audio sample for trackId, if sample is undefined it only changes the tracks
ProtectedreadProtectedreadProtectedreadUtility dispatcher that forwards a media sample to the appropriate reader (readAudio, readVideo, or readData) based on its type.
This is a convenience method — callers may invoke readAudio, readVideo, or readData directly if the media type is already known.
ProtectedreadIngest video sample for trackId, if sample is undefined it only changes the tracks If sample.duration is negative, it will extend the sample until the currentTime to repair synchronization
Protected AbstractsetProtectedsetProtected AbstractsetStaticgetRetrieves the Source class registered for the specified protocol.
The name of the protocol (e.g., 'wss', 'https', 'http').
The registered Source class implementation for the protocol, or undefined if not found.
StaticregisterRegisters a Source class for one or multiple protocols, see getClass to retrieve the registered Source class.
One or more protocol names (e.g., 'wss', 'https', 'http'), at least one protocol is required.
A decorator that registers the given Source class under the specified protocols.
Fire when source is closed
Optionalerror: SourceErrorerror description on an improper closure
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 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.
// Set the initial video track to the highest quality; MBR will adjust it later based on network conditions.
player.onMetadata = (metadata) => ({ video: metadata.videoTracks[0].id });
// Alternatively, disable MBR and lock the video track to the highest available quality.
player.onMetadata = (metadata) => player.videoTrack = metadata.videoTracks[0].id;
Fire on a track change
Abstract Source class to implement a Media Source