ServerSideAdIntegrationHandler

public protocol ServerSideAdIntegrationHandler

A handler for a server-side ad integration.

You can implement one or more of these methods to hook into various parts of the player’s lifecycle and perform your integration-specific ad handling.

Use the ServerSideAdIntegrationController provided by Ads.registerServerSideIntegration to update the state of your integration.

Remark

Experimental
  • setSource(source:) Default implementation

    Handler which will be called when a new source is loaded into the player.

    This allows the integration to transform the source description, e.g. by calling an external service to replace TypedSource.src (the content URL), or by adding a fixed pre-roll linear ad to SourceDescription.ads (the list of ads).

    Default Implementation

    Declaration

    Swift

    func setSource(source: SourceDescription) -> Bool

    Parameters

    source

    The original source description.

    Return Value

    Returns whether the handler will be responsible for transforming the source. Should return false in order to invoke default player behavior.

  • skipAd(ad:) Default implementation

    Handler which will be called when an ad is requested to be skipped.

    To skip the ad, the handler should call ServerSideAdIntegrationController.skipAd.

    Remark

    This is only called for ads whose Ad.integration matches ServerSideAdIntegrationController.integration.

    Default Implementation

    Declaration

    Swift

    func skipAd(ad: Ad) -> Bool

    Parameters

    ad

    The Ad to be skipped.

    Return Value

    Returns whether the handler will be responsible for skipping the ad. Should return false in order to invoke default player behavior.

  • resetSource() Default implementation

    Handler which will be called before a new source is loaded into the player, or before the player is destroyed.

    This allows the integration to clean up any source-specific resources, such as scheduled ads or pending HTTP requests.

    Remark

    If this handler is missing, the player will remove all remaining ads by callingServerSideAdIntegrationController.removeAllAds.

    Default Implementation

    Declaration

    Swift

    func resetSource() -> Bool

    Return Value

    Returns whether the handler will be responsible for resetting the source. Should return false in order to invoke default player behavior.

  • destroy() Default implementation

    Handler which will be called when the player is destroyed.

    This allows the integration to clean up any resources, such as event listeners.

    Default Implementation

    Declaration

    Swift

    func destroy()