com.brightcove.player.ads

## Class ExoAdPlayer

- java.lang.Object
- - com.brightcove.player.event.AbstractComponent
  - - com.brightcove.player.ads.ExoAdPlayer

- All Implemented Interfaces:
    AdPlayer<AdAsset>, Component

      @ListensFor(events={"activityPaused","activityResumed","fragmentPaused","fragmentResumed","adBreakStarted","adBreakCompleted"})
       @Emits(events={"adBreakStarted","adStarted","adCompleted","adBreakCompleted","adResumed","adPaused","adProgress","adError","willInterruptContent","willResumeContent","play"})
      public final class ExoAdPlayer
      extends AbstractComponent
      implements AdPlayer<AdAsset>

  Implementation of an `AdPlayer` using ExoPlayer. ExoAdPlayer handles `AdAsset` as the type of Ads to be played.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.brightcove.player.ads.AdPlayer

      `AdPlayer.AdPlayerSettings, AdPlayer.Listener<T>`

  - ### Field Summary

    - ### Fields inherited from class com.brightcove.player.event.AbstractComponent

      `eventEmitter, listenerTokens`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addListener(AdPlayer.Listener<AdAsset> listener)` Adds a `AdPlayer.Listener`.
    `static ExoAdPlayer` | `create(BaseVideoView baseVideoView)` Creates an ExoAdPlayer and adds a PlayerView in the BaseVideoView.
    `static ExoAdPlayer` | `create(BaseVideoView baseVideoView, AdPlayer.AdPlayerSettings adPlayerSettings)` Creates an ExoAdPlayer and adds a PlayerView in the BaseVideoView.
    `static ExoAdPlayer` | `create(android.view.ViewGroup viewGroup, EventEmitter eventEmitter, AdPlayer.AdPlayerSettings adPlayerSettings)` Creates an ExoAdPlayer and adds a PlayerView in the provided `ViewGroup`.
    `void` | `loadAd(AdAsset adAsset)` Loads an ad of type T.
    `void` | `pauseAd()` Pauses an ad.
    `void` | `playAd()` Plays an ad.
    `void` | `release()` Releases the `AdPlayer`.
    `void` | `removeListener(AdPlayer.Listener<AdAsset> listener)` Removes a `AdPlayer.Listener`.
    `void` | `seekTo(long position)` Seeks to the specified position.
    `void` | `skipAd()` Skips the current ad.
    `void` | `stop()`

    - ### Methods inherited from class com.brightcove.player.event.AbstractComponent

      `addListener, addOnceListener, getEventEmitter, removeListener, removeListeners`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### create

          public static ExoAdPlayer create(@NonNull
                                           BaseVideoView baseVideoView)

      Creates an ExoAdPlayer and adds a PlayerView in the BaseVideoView. Note: This method must be called from the UI thread.
      Parameters:
        `baseVideoView` - where the Ad will be rendered.
      Returns:
        a new instance of an ExoAdPlayer.

    - #### create

          public static ExoAdPlayer create(@NonNull
                                           BaseVideoView baseVideoView,
                                           @Nullable
                                           AdPlayer.AdPlayerSettings adPlayerSettings)

      Creates an ExoAdPlayer and adds a PlayerView in the BaseVideoView. Note: This method must be called from the UI thread.
      Parameters:
        `baseVideoView` - where the Ad will be rendered.
        `adPlayerSettings` - configuration object for the ad player
      Returns:
        a new instance of an ExoAdPlayer.

    - #### create

          public static ExoAdPlayer create(@NonNull
                                           android.view.ViewGroup viewGroup,
                                           @NonNull
                                           EventEmitter eventEmitter,
                                           @Nullable
                                           AdPlayer.AdPlayerSettings adPlayerSettings)

      Creates an ExoAdPlayer and adds a PlayerView in the provided `ViewGroup`. Note: This method must be called from the UI thread.
      Parameters:
        `viewGroup` - where the Ad will be rendered.
        `eventEmitter` - the event emitter
        `adPlayerSettings` - configuration object for the ad player
      Returns:
        a new instance of an ExoAdPlayer.

    - #### loadAd

          public void loadAd(@NonNull
                             AdAsset adAsset)

      Description copied from interface: `AdPlayer`
      Loads an ad of type T.
      Specified by:
        `loadAd` in interface `AdPlayer<AdAsset>`
      Parameters:
        `adAsset` - ad to be loaded.

    - #### addListener

          public void addListener(@NonNull
                                  AdPlayer.Listener<AdAsset> listener)

      Description copied from interface: `AdPlayer`
      Adds a `AdPlayer.Listener`.
      Specified by:
        `addListener` in interface `AdPlayer<AdAsset>`
      Parameters:
        `listener` - listener to be added.

    - #### removeListener

          public void removeListener(@NonNull
                                     AdPlayer.Listener<AdAsset> listener)

      Description copied from interface: `AdPlayer`
      Removes a `AdPlayer.Listener`.
      Specified by:
        `removeListener` in interface `AdPlayer<AdAsset>`
      Parameters:
        `listener` - listener to be removed.

    - #### playAd

          public void playAd()

      Description copied from interface: `AdPlayer`
      Plays an ad.
      Specified by:
        `playAd` in interface `AdPlayer<AdAsset>`

    - #### pauseAd

          public void pauseAd()

      Description copied from interface: `AdPlayer`
      Pauses an ad.
      Specified by:
        `pauseAd` in interface `AdPlayer<AdAsset>`

    - #### seekTo

          public void seekTo(long position)

      Description copied from interface: `AdPlayer`
      Seeks to the specified position.
      Specified by:
        `seekTo` in interface `AdPlayer<AdAsset>`

    - #### release

          public void release()

      Description copied from interface: `AdPlayer`
      Releases the `AdPlayer`.
      Specified by:
        `release` in interface `AdPlayer<AdAsset>`

    - #### skipAd

          public void skipAd()

      Description copied from interface: `AdPlayer`
      Skips the current ad.
      Specified by:
        `skipAd` in interface `AdPlayer<AdAsset>`

    - #### stop

          public void stop()