Source

@objc(BMPSource)
public protocol Source : SourceEventHandler

Represents audio and video content that can be loaded into a Player. A Source instance can be created via the SourceFactory.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 SourceEventHandler 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.

Only a few events are currently emitted from the source. This is a temporary limitation until all source events are emitted correctly from the source. See SourceListener for more information about events emitted from the source.

  • The SourceConfig that was used to configure the source.

    Declaration

    Swift

    var sourceConfig: SourceConfig { get }
  • 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).

    Declaration

    Swift

    var isAttachedToPlayer: Bool { get }
  • 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.

    Declaration

    Swift

    var isActive: Bool { get }
  • The duration of the source in seconds if it’s a VoD or Double.infinity if it’s a live stream. Default value is 0 if the duration is not available or not known.

    Declaration

    Swift

    var duration: TimeInterval { get }
  • The current LoadingState of the source.

    Declaration

    Swift

    var loadingState: LoadingState { get }
  • Metadata for the currently loaded source. All existing metadata will be completely replaced by the provided metadata when the setter is called. For example, if sourceMetadata is an empty object, all existing source metadata will be deleted. Setting new metadata results in a SourceMetadataChanged event to be emitted. The initial value can be set via SourceConfig.metadata.

    Declaration

    Swift

    var metadata: [String : AnyObject]? { get set }