# IMA Class

    public class IMA: BaseComponent, IMAContentPlayhead, IMAAdsLoaderDelegate, IMAAdsManagerDelegate,
        ViewBasedComponentProtocol

    extension IMA: AdsComponentProtocol

    extension IMA: AdsAPI

### Lifecycle

- `init(for:_:settings:)`

  Default initializer with Ads API

  #### Declaration

  Swift

      public init(for session: Session, _ adsDispatcher: AdsDispatcherProtocol, settings: AdsSettings? = nil)

  #### Parameters

  `adsDispatcher` | state changes dispatcher

### Public

- `playAdsAfterTime`

  #### Declaration

  Swift

      public var playAdsAfterTime: Double

- `adCuePoints`

  Array of double values in seconds.`nil` for single ads or if no ad breaks are scheduled.

  #### Declaration

  Swift

      public var adCuePoints: [Double]?

- `pauseOnTap`

  if `true` pause ad playback on tap event

  #### Declaration

  Swift

      public var pauseOnTap: Bool

- `onAdsState`

  #### Declaration

  Swift

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

- `onCurrentTime`

  #### Declaration

  Swift

      public var onCurrentTime: ((Double, Double) -> Void)?

### IMAContentPlayhead

- `currentTime`

  Reflects the current playback time in seconds for the content

  #### Declaration

  Swift

      public var currentTime: TimeInterval

- `adsLoader(_:adsLoadedWith:)`

  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

- `adsLoader(_:failedWith:)`

  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

- `playerLayerAttached(_:)`

  Description

  #### Declaration

  Swift

      public func playerLayerAttached(_: CALayer)

  #### Parameters

  `playerLayer` | playerLayer description

- `viewSizeTransition(_:)`

  Updates current view size Current implementation respects safe area insets

  #### Declaration

  Swift

      public func viewSizeTransition(_ size: CGSize)

  #### Parameters

  `size` | new size

- `adsManager(_:didReceive:)`

  Called when there is an IMAAdEvent

  #### Declaration

  Swift

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

  #### Parameters

  `adsManager` | ads manager
  `event` | event received

- `adsManager(_:didReceive:)`

  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

- `adsManagerDidRequestContentPause(_:)`

  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

- `adsManagerDidRequestContentResume(_:)`

  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

- `adsManagerAdDidStartBuffering(_:)`

  #### Declaration

  Swift

      public func adsManagerAdDidStartBuffering(_ adsManager: IMAAdsManager)

- `adsManagerAdPlaybackReady(_:)`

  #### Declaration

  Swift

      public func adsManagerAdPlaybackReady(_ adsManager: IMAAdsManager)

- `adsManager(_:adDidProgressToTime:totalTime:)`

  #### Declaration

  Swift

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

### AdsComponentProtocol

- `start()`

  Starts advertisement playback

  #### Declaration

  Swift

      public func start()

- `pause()`

  Pauses advertisement

  #### Declaration

  Swift

      public func pause()

- `resume()`

  Resumes the advertisement

  #### Declaration

  Swift

      public func resume()

- `skip()`

  Skips the advertisement if the ad is skippable and the skip offset has been reached

  #### Declaration

  Swift

      public func skip()

- `destroy()`

  Causes the ads manager to stop the ad and clean its internal state

  #### Declaration

  Swift

      public func destroy()

- `discardAdBreak()`

  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

- `isAdPlaying`

  Common ads state

  #### Declaration

  Swift

      public var isAdPlaying: Bool { get }

- `requestAds(withUrl:onView:viewController:)`

  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

- `requestAds(withAdsResponse:onView:viewController:)`

  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