IMA Class

public class IMA: BaseComponent, IMAContentPlayhead, IMAAdsLoaderDelegate, IMAAdsManagerDelegate,
    ViewBasedComponentProtocol
extension IMA: AdsComponentProtocol
extension IMA: AdsAPI

Lifecycle

  • Default initializer with Ads API

    Declaration

    Swift

    public init(for session: Session, _ adsDispatcher: AdsDispatcherProtocol)

    Parameters

    adsDispatcher

    state changes dispatcher

Internal

  • if true pause ad playback on tap event

    Declaration

    Swift

    public var pauseOnTap: Bool
  • Declaration

    Swift

    public var onAdsState: ((AdsState) -> Void)?

IMAContentPlayhead

  • Reflects the current playback time in seconds for the content

    Declaration

    Swift

    public var currentTime: TimeInterval
  • Called when ads are successfully loaded from the ad servers by the loader

    Declaration

    Swift

    public func adsLoader(_: IMAAdsLoader, adsLoadedWith adsLoadedData: IMAAdsLoadedData)

    Parameters

    loader

    ads loader

    adsLoadedData

    ads data

  • Error dispatched by the ads loader when loading or requesting an ad fails

    Declaration

    Swift

    public func adsLoader(_: IMAAdsLoader, failedWith adErrorData: IMAAdLoadingErrorData)

    Parameters

    loader

    ads laoder

    adErrorData

    ad loading error

  • Description

    Declaration

    Swift

    public func playerLayerAttached(_: CALayer)

    Parameters

    playerLayer

    playerLayer description

  • Updates current view size Current implementation makes it full screen

    Declaration

    Swift

    public func viewSizeTransition(_ size: CGSize)

    Parameters

    size

    new size

  • Called when there is an IMAAdEvent

    Declaration

    Swift

    public func adsManager(_ adsManager: IMAAdsManager, didReceive event: IMAAdEvent)

    Parameters

    adsManager

    ads manager

    event

    event received

  • Called when there was an error playing the ad. Log the error and resume playing content.

    Declaration

    Swift

    public func adsManager(_ adsManager: IMAAdsManager, didReceive error: IMAAdError)

    Parameters

    adsManager

    ads manager

    error

    error received

  • Called when an ad is ready to play. The implementing code should pause the content playback and prepare the UI for ad playback

    Declaration

    Swift

    public func adsManagerDidRequestContentPause(_ adsManager: IMAAdsManager)

    Parameters

    adsManager

    ads manager

  • Called when an ad has finished or an error occurred during the playback. The implementing code should resume the content playback.

    Declaration

    Swift

    public func adsManagerDidRequestContentResume(_ adsManager: IMAAdsManager)

    Parameters

    adsManager

    ads manager

  • Declaration

    Swift

    public func adsManagerAdDidStartBuffering(_ adsManager: IMAAdsManager)
  • Declaration

    Swift

    public func adsManagerAdPlaybackReady(_ adsManager: IMAAdsManager)
  • Declaration

    Swift

    public func adsManager(
        _ adsManager: IMAAdsManager,
        adDidProgressToTime mediaTime: TimeInterval,
        totalTime: TimeInterval)

AdsComponentProtocol

  • Starts advertisement playback

    Declaration

    Swift

    public func start()
  • Pauses advertisement

    Declaration

    Swift

    public func pause()
  • Resumes the advertisement

    Declaration

    Swift

    public func resume()
  • Skips the advertisement if the ad is skippable and the skip offset has been reached

    Declaration

    Swift

    public func skip()
  • Causes the ads manager to stop the ad and clean its internal state

    Declaration

    Swift

    public func destroy()
  • If an ad break is currently playing, discard it and resume content Otherwise, ignore the next scheduled ad break

    Declaration

    Swift

    public func discardAdBreak()

Internal

  • Common ads state

    Declaration

    Swift

    public var isAdPlaying: Bool { get }
  • Request ads from the ad server from given url

    Declaration

    Swift

    public func requestAds(
        withUrl url: URL,
        onView view: UIView,
        viewController: UIViewController?)

    Parameters

    url

    request ad url

  • Request ads from the ad server from given Ads Response

    Declaration

    Swift

    public func requestAds(
        withAdsResponse response: String,
        onView view: UIView,
        viewController: UIViewController?)

    Parameters

    response

    hardcoded response