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 }
  • The _SourceModulesApi for interactions regarding modules.

    Declaration

    Swift

    var _modules: _SourceModulesApi { get }
  • The SourceEventsApi for interactions regarding event publishers. This API is only available for usage from Swift.

    Declaration

    Swift

    var events: SourceEventsApi { get }
  • drm

    The SourceDrmApi for interactions regarding DRM specific APIs.

    Declaration

    Swift

    var drm: SourceDrmApi { get }
  • Returns the thumbnail image for a certain time. Requires a configured ThumbnailTrack in the corresponding SourceConfig.

    Note

    This function returns nil
    • If the thumbnails were not loaded yet
    • If there are no ThumbnailTrack provided in the corresponding SourceConfig
    • If there is no thumbnail available at the provided time

    Declaration

    Swift

    func thumbnail(forTime time: TimeInterval) -> Thumbnail?

    Parameters

    time

    The time for which the thumbnail should be returned.

    Return Value

    An instance of Thumbnail for the given time, or nil.

  • A list of TimelineMarker. Currently, the only type of supported marker is InterstitialMarker. See documentation of InterstitialMarker for more information.

    When a TimelineMarker is entered during playback, a TimelineMarkerEnterEvent is emitted. When a TimelineMarker is exited during playback, a TimelineMarkerExitEvent is emitted.

    The initial value can be set via SourceConfig.markers.

    Declaration

    Swift

    @available(tvOS 14.0, *)
    @available(iOS, unavailable)
    var markers: [TimelineMarker] { get set }
  • analytics Extension method

    Allows access to the Analytics APIs

    Returns nil if Analytics is not enabled for the Source

    Declaration

    Swift

    var analytics: SourceAnalyticsApi? { get }