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.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun getThumbnail(time: Double): Thumbnail?

Returns a Thumbnail for the provided playback time. Supported thumbnail formats are

Link copied to clipboard
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.

Link copied to clipboard
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.

Link copied to clipboard
abstract fun setAudioTrack(trackId: String)

Sets the AudioTrack that corresponds to the trackId. A list of currently available AudioTracks can be retrieved via availableAudioTracks.

Link copied to clipboard
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.

Link copied to clipboard
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.

Properties

Link copied to clipboard

A list of available AudioQualitys of the selected AudioTrack from the currently active period in the source.

Link copied to clipboard

A list of available AudioTracks from the currently active period in the source.

Link copied to clipboard

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.

Link copied to clipboard

A list of available VideoQualitys from the currently active period in the source.

Link copied to clipboard
abstract val config: SourceConfig

The SourceConfig that was used to configure the source.

Link copied to clipboard
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.

Link copied to clipboard
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.

Link copied to clipboard

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).

Link copied to clipboard

The current LoadingState of the source.

Link copied to clipboard
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.

Link copied to clipboard

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.

Link copied to clipboard

The currently selected AudioTrack.

Link copied to clipboard

The currently selected SubtitleTrack.

Link copied to clipboard

The currently selected VideoQuality or a video quality with the ID Quality.AUTO_ID if no fixed video quality is selected.