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:ad:) Asynchronous

    Loads and plays an ad source until it ends or stop() is called.

    Declaration

    Swift

    @MainActor
    func load(source: TypedSource, ad: Ad?) async throws

    Parameters

    source

    The media source to play.

    ad

    The ad associated with this playback, or nil when the integration manages ad lifecycle itself.

  • preload(source:) Asynchronous

    A later load(source:ad:) with the same src and type reuses 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.preloadWhileInPictureInPicture while 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