Source

interface Source : EventEmitter<SourceEvent>

Represents audio and video content that can be loaded into a Player. 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 playlist immediately becomes active. When the player transitions to another source in the playlist, 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.

Current event-related limitations

Only the following events are currently emitted from the source. SourceEvents not declared in this list are only emitted from the Player. This is a temporary limitation until all source events are emitted correctly from the source.

Types

Companion
Link copied to clipboard
object Companion

Properties

config
Link copied to clipboard
abstract val config: SourceConfig
The SourceConfig that was used to configure the source.
duration
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.
isActive
Link copied to clipboard
abstract val isActive: Boolean
Whether the source is currently active in a Player (i.e.
isAttachedToPlayer
Link copied to clipboard
abstract val isAttachedToPlayer: Boolean
Whether the source is currently attached to a player instance (i.
loadingState
Link copied to clipboard
abstract val loadingState: LoadingState
The current LoadingState of the source.

Inherited functions

next
Link copied to clipboard
open override fun <E : SourceEvent> next(eventClass: Class<E>, eventListener: EventListener<E>)
Subscribes the eventListener to be executed when the next event of type E is emitted.
abstract fun <E : SourceEvent> next(eventClass: KClass<E>, action: (E) -> Unit)
Subscribes the action to be executed when the next event of type E is emitted.
off
Link copied to clipboard
open override fun <E : SourceEvent> off(eventListener: EventListener<E>)
Unsubscribes the eventListener for all events.
abstract fun <E : SourceEvent> off(action: (E) -> Unit)
Unsubscribes the action for all events.
open override fun <E : SourceEvent> off(eventClass: Class<E>, eventListener: EventListener<E>)
Unsubscribes the eventListener for the specified event.
abstract fun <E : SourceEvent> off(eventClass: KClass<E>, action: (E) -> Unit)
Unsubscribes the action for the specified event.
on
Link copied to clipboard
open override fun <E : SourceEvent> on(eventClass: Class<E>, eventListener: EventListener<E>)
Subscribes the eventListener to be executed when an event of type E is emitted.
abstract fun <E : SourceEvent> on(eventClass: KClass<E>, action: (E) -> Unit)
Subscribes the action to be executed when an event of type E is emitted.