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.
Current event-related limitations
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
PlaylistConfigthat 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.infinityif it’s a live stream. Default value is0if the duration is not available or not known.Declaration
Swift
var duration: TimeInterval { get } -
The current
LoadingStateof 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
SourceMetadataChangedevent to be emitted. The initial value can be set viaSourceConfig.metadata.Declaration
Swift
var metadata: [String : AnyObject]? { get set } -
The
_SourceModulesApifor interactions regarding modules.Declaration
Swift
var _modules: _SourceModulesApi { get } -
The
SourceEventsApifor interactions regarding event publishers. This API is only available for usage from Swift.Declaration
Swift
var events: SourceEventsApi { get } -
The
SourceDrmApifor interactions regarding DRM specific APIs.Declaration
Swift
var drm: SourceDrmApi { get } -
Returns the thumbnail image for a certain time. Requires a configured
ThumbnailTrackin the correspondingSourceConfig.Note
This function returnsnil- If the thumbnails were not loaded yet
- If there are no
ThumbnailTrackprovided in the correspondingSourceConfig If there is no thumbnail available at the provided time
Declaration
Swift
func thumbnail(forTime time: TimeInterval) -> Thumbnail?Parameters
timeThe time for which the thumbnail should be returned.
Return Value
An instance of
Thumbnailfor the given time, ornil. -
A list of
TimelineMarker. Currently, the only type of supported marker isInterstitialMarker. See documentation ofInterstitialMarkerfor more information.When a
TimelineMarkeris entered during playback, aTimelineMarkerEnterEventis emitted. When aTimelineMarkeris exited during playback, aTimelineMarkerExitEventis emitted.The initial value can be set via
SourceConfig.markers.Declaration
Swift
@available(tvOS 14.0, *) @available(iOS, unavailable) var markers: [TimelineMarker] { get set } -
analyticsExtension methodAllows access to the Analytics APIs
Returns
nilif Analytics is not enabled for theSourceDeclaration
Swift
var analytics: SourceAnalyticsApi? { get }
Source Protocol Reference