LinearAdPlayer
@MainActor
public protocol LinearAdPlayer : EventDispatcherProtocol, LinearAdPlayback
A built-in player for media-backed linear ads in a client-side ad integration.
Remark
This API is experimental and may change in a future version.-
The stable view hosting the built-in player.
Declaration
Swift
@MainActor var view: UIView { get } -
load(source:Asynchronousad: ) Loads and plays an ad source until it ends or
stop()is called.Declaration
Swift
@MainActor func load(source: TypedSource, ad: Ad?) async throwsParameters
sourceThe media source to play.
adThe ad associated with this playback, or
nilwhen the integration manages ad lifecycle itself. -
preload(source:Asynchronous) A later
load(source:ad:)with the samesrcandtypereuses the preload.Preloading works during or outside a linear ad break. Only one source is preloaded at a time, and a preload failure does not emit an ad error.
Throws
LinearAdPlayerError.preloadWhileInPictureInPicturewhile native Picture-in-Picture shows an ad of this player.load(source:ad:)keeps working there.Declaration
Swift
@MainActor func preload(source: TypedSource) async throws -
Stops the current source, ends its associated ad when present, and resolves its pending load.
Declaration
Swift
@MainActor func stop() -
load(source:Extension method, asynchronous) Loads and plays a source without associating an ad object.
Declaration
Swift
@MainActor func load(source: TypedSource) async throws