Source
interface Source : EventEmitter<SourceEvent>
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() 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.
A note on threading:
The Source instance must be created and accessed on the application's main thread.
Types
| Name | Summary |
|---|---|
| Companion | object Companion |
Properties
| Name | Summary |
|---|---|
| availableAudioQualities | abstract val availableAudioQualities: List<AudioQuality> A list of available AudioQualitys of the selected AudioTrack from the currently active period in the source. |
| availableAudioTracks | abstract val availableAudioTracks: List<AudioTrack> A list of available AudioTracks from the currently active period in the source. |
| availableSubtitleTracks | abstract val availableSubtitleTracks: List<SubtitleTrack> 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. |
| availableVideoQualities | abstract val availableVideoQualities: List<VideoQuality> A list of available VideoQualitys from the currently active period in the source. |
| config | abstract val config: SourceConfig The SourceConfig that was used to configure the source. |
| duration | abstract val duration: Double 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. |
| isActive | abstract val isActive: Boolean Whether the source is currently active in a Player (i.e. playing back or paused). Only one source can be active in the same player instance at any time. |
| isAttachedToPlayer | abstract val isAttachedToPlayer: Boolean 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). |
| loadingState | abstract val loadingState: LoadingState The current LoadingState of the source. |
| seekableRange | abstract val seekableRange: TimeRange 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. |
| selectedAudioQuality | abstract val selectedAudioQuality: AudioQuality? 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. |
| selectedAudioTrack | abstract val selectedAudioTrack: AudioTrack? The currently selected AudioTrack. |
| selectedSubtitleTrack | abstract val selectedSubtitleTrack: SubtitleTrack? The currently selected SubtitleTrack. |
| selectedVideoQuality | abstract val selectedVideoQuality: VideoQuality? The currently selected VideoQuality or a video quality with the ID Quality.AUTO_ID if no fixed video quality is selected. |
Functions
| Name | Summary |
|---|---|
| getThumbnail | abstract fun getThumbnail(time: Double): Thumbnail? Returns a Thumbnail for the provided playback time. Supported thumbnail formats are |
| removeSubtitleTrack | abstract fun removeSubtitleTrack(trackId: String) 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. |
| setAudioQuality | abstract fun setAudioQuality(qualityId: String) 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. |
| setAudioTrack | abstract fun setAudioTrack(trackId: String) Sets the AudioTrack that corresponds to the trackId. A list of currently available AudioTracks can be retrieved via availableAudioTracks. |
| setSubtitleTrack | abstract fun setSubtitleTrack(trackId: String?) 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. |
| setVideoQuality | abstract fun setVideoQuality(qualityId: String) 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. |