Source
Represents audio and video content that can be loaded into a Player to start a playback session. A source instance can be created via the Source.create function and will idle until it is loaded into a player. After loading the source into a player, isAttachedToPlayer is true and the same source can not be loaded into a different player until unloaded.
Multiple sources can be loaded into a player as part of a PlaylistConfig, where the first source in the playback session immediately becomes active. When the player transitions to another source in the playback session, that source becomes active. More information on how to manage multiple sources can be found on the PlaylistApi.
The source starts out LoadingState.Unloaded, transitions to LoadingState.Loading once the source starts loading and finally transitions to LoadingState.Loaded when it finished loading. When unloaded from a player, the source reverts to being LoadingState.Unloaded and detached. After this, the source can be loaded again into a (different) player.
The source emits events while it is attached to a player. See EventEmitter on how to subscribe to events. The source only emits events of type SourceEvent, and events that are emitted while the source is active are also emitted through the player it is attached to.
Functions
Removes the existing SubtitleTrack with trackId from the list of available subtitle tracks. If the track is currently selected, it will be de-selected and then removed. If no SubtitleTrack with the given trackId exists, the call has no effect. Use setSubtitleTrack and pass null
as the trackId
to just disable but not remove an active SubtitleTrack.
Sets a fixed AudioQuality identified by a qualityId. A list of currently available AudioQualitys can be retrieved via availableAudioQualities. To use automatic quality selection, Quality.AUTO_ID can be passed as qualityId.
Sets the AudioTrack that corresponds to the trackId. A list of currently available AudioTracks can be retrieved via availableAudioTracks.
Enables the SubtitleTrack that corresponds to the trackId. A list of currently available SubtitleTracks can be retrieved via availableSubtitleTracks. Providing null
as the trackId disables subtitles.
Sets a fixed VideoQuality identified by a qualityId. A list of currently available VideoQualitys can be retrieved via availableVideoQualities. To use automatic quality selection, Quality.AUTO_ID can be passed as qualityId.
Properties
A list of available AudioQualitys of the selected AudioTrack from the currently active period in the source.
A list of available AudioTracks from the currently active period in the source.
A list of available SubtitleTracks from the currently active period in the source. Side-loaded subtitle tracks added via SourceConfig.subtitleTracks are available across all periods of the source.
A list of available VideoQualitys from the currently active period in the source.
The SourceConfig that was used to configure the source.
The duration of the source in seconds if it's a VoD or Double.POSITIVE_INFINITY if it's a live stream. Defaults to -1.0 if the duration is not available or not known.
Whether the source is currently attached to a player instance (i.e if the source was loaded into a player or it is part of a PlaylistConfig that was loaded into a player).
The current LoadingState of the source.
A TimeRange that includes all possible playback time values between the start and the end of the source. Values in the time range are valid for seek operations via Player.seek or PlaylistApi.seek.
The currently selected AudioQuality of the selected AudioTrack or an audio quality with the ID Quality.AUTO_ID if no fixed audio quality is selected.
The currently selected AudioTrack.
The currently selected SubtitleTrack.
The currently selected VideoQuality or a video quality with the ID Quality.AUTO_ID if no fixed video quality is selected.