Package com.castlabs.android.adverts

## Interface AdInterface

-     public interface AdInterface

  Implementation of this interface provides access to Ad status. It also allows to inject side-interpreted ads events that are used for analytics and in app callbacks.
  Since:
    3.2.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface | Description
    --- | --- | ---
    `static interface` | `AdInterface.Listener` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `adCompleted()` | Inject the ad completed side event
    `void` | `addAdListener​(AdInterface.Listener listener)` | Register the given `AdInterface.Listener`
    `void` | `adError​(CastlabsPlayerException exception)` | Inject the ad error side event
    `void` | `adSkipped()` | Inject the ad skipped side event
    `void` | `adStarted​(Ad ad)` | Inject the ad started side event.
    `AdApi` | `getAdApi()` | Get an `AdApi` to issue custom operations to the ad provider
    `long` | `getPosition()` | Get the Ad position in microseconds.
    `boolean` | `isPlaying()` | Check the Ad is currently playing.
    `void` | `removeAdListener​(AdInterface.Listener listener)` | Remove the given `AdInterface.Listener`
    `void` | `scheduleAd​(AdRequest adRequest)` | Manually schedules an `AdRequest`.
    `void` | `showAdUi​(boolean showUi)` | Whether to show the default ad UI from the ad provider

- - ### Method Detail

    - #### addAdListener

          void addAdListener​(@NonNull
                             AdInterface.Listener listener)

      Register the given `AdInterface.Listener`
      Parameters:
        `listener` - the listener

    - #### removeAdListener

          void removeAdListener​(@NonNull
                                AdInterface.Listener listener)

      Remove the given `AdInterface.Listener`
      Parameters:
        `listener` - the listener

    - #### isPlaying

          boolean isPlaying()

      Check the Ad is currently playing.
      Returns:
        true if the Ad is currently playing otherwise false

    - #### getPosition

          long getPosition()

      Get the Ad position in microseconds.
      Returns:
        positionUs the position in microseconds

    - #### adStarted

          void adStarted​(@NonNull
                         Ad ad)

      Inject the ad started side event.
      Parameters:
        `ad` - The ad

    - #### adCompleted

          void adCompleted()

      Inject the ad completed side event

    - #### adError

          void adError​(CastlabsPlayerException exception)

      Inject the ad error side event
      Parameters:
        `exception` - The error's exception

    - #### adSkipped

          void adSkipped()

      Inject the ad skipped side event

    - #### scheduleAd

          void scheduleAd​(@NonNull
                          AdRequest adRequest)

      Manually schedules an `AdRequest`. This can be called once playback is already started as long as the underlying AdLoader is compatible and manual ad scheduling `is enabled`. You can also use `SdkConsts.AD_SCHEDULE_MANUAL`. Note that if any other ads had been previously scheduled, such will be replaced by the new request.
      Parameters:
        `adRequest` - the AdRequest to schedule
      Since:
        4.2.24

    - #### showAdUi

          void showAdUi​(boolean showUi)

      Whether to show the default ad UI from the ad provider
      Parameters:
        `showUi` - show the ui

    - #### getAdApi

          @Nullable
          AdApi getAdApi()

      Get an `AdApi` to issue custom operations to the ad provider
      Returns:
        the `AdApi`