docs/doc/reference/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.html
Package com.google.android.exoplayer2.ext.ima
All Implemented Interfaces:AdsLoader
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classImaAdsLoaderextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[AdsLoader](../../source/ads/AdsLoader.html "interface in com.google.android.exoplayer2.source.ads")
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
AdsLoader using the IMA SDK. All methods must be called on the main thread.
The player instance that will play the loaded ads must be set before playback using setPlayer(Player). If the ads loader is no longer required, it must be released by calling release().
See IMA's Support and compatibility page for information on compatible ad tag formats. Pass the ad tag URI when setting media item playback properties (if using the media item API) or as a DataSpec when constructing the AdsMediaSource (if using media sources directly). For the latter case, please note that this implementation delegates loading of the data spec to the IMA SDK, so range and headers specifications will be ignored in ad tag URIs. Literal ads responses can be encoded as data scheme data specs, for example, by constructing the data spec using a URI generated via Util.getDataUriForString(String, String).
The IMA SDK can report obstructions to the ad view for accurate viewability measurement. This means that any overlay views that obstruct the ad overlay but are essential for playback need to be registered via the AdViewProvider passed to the AdsMediaSource. See the IMA SDK Open Measurement documentation for more information.
Nested Classes | Modifier and Type | Class | Description |
| --- | --- | --- |
| static class | ImaAdsLoader.Builder |
Deprecated.
Builder for ImaAdsLoader.
|
-
AdsLoader.EventListener, AdsLoader.Provider
All Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| void | focusSkipButton() |
Deprecated.
Moves UI focus to the skip button (or other interactive elements), if currently shown.
|
| com.google.ads.interactivemedia.v3.api.AdDisplayContainer | getAdDisplayContainer() |
Deprecated.
Returns the AdDisplayContainer used by this loader, or null if ads have not been requested yet.
|
| com.google.ads.interactivemedia.v3.api.AdsLoader | getAdsLoader() |
Deprecated.
Returns the underlying AdsLoader wrapped by this instance, or null if ads have not been requested yet.
|
| void | handlePrepareComplete(AdsMediaSource adsMediaSource, int adGroupIndex, int adIndexInAdGroup) |
Deprecated.
Notifies the ads loader that preparation of an ad media period is complete.
|
| void | handlePrepareError(AdsMediaSource adsMediaSource, int adGroupIndex, int adIndexInAdGroup, IOException exception) |
Deprecated.
Notifies the ads loader that the player was not able to prepare media for a given ad.
|
| void | release() |
Deprecated.
Releases the loader.
|
| void | requestAds(DataSpec adTagDataSpec, Object adsId, ViewGroup adViewGroup) |
Deprecated.
Requests ads, if they have not already been requested.
|
| void | setPlayer(Player player) |
Deprecated.
Sets the player that will play the loaded ads.
|
| void | setSupportedContentTypes(@com.google.android.exoplayer2.C.ContentType int... contentTypes) |
Deprecated.
Sets the supported content types for ad media.
|
| void | skipAd() |
Deprecated.
Skips the current ad.
|
| void | start(AdsMediaSource adsMediaSource, DataSpec adTagDataSpec, Object adsId, AdViewProvider adViewProvider, AdsLoader.EventListener eventListener) |
Deprecated.
Starts using the ads loader for playback.
|
| void | stop(AdsMediaSource adsMediaSource, AdsLoader.EventListener eventListener) |
Deprecated.
Stops using the ads loader for playback and deregisters the event listener. |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
@Nullable
public com.google.ads.interactivemedia.v3.api.AdsLoader getAdsLoader()
Deprecated.
Returns the underlying AdsLoader wrapped by this instance, or null if ads have not been requested yet.
-
@Nullable
public com.google.ads.interactivemedia.v3.api.AdDisplayContainer getAdDisplayContainer()
Deprecated.
Returns the AdDisplayContainer used by this loader, or null if ads have not been requested yet.
Note: any video controls overlays registered via BaseDisplayContainer.registerFriendlyObstruction(FriendlyObstruction) will be unregistered automatically when the media source detaches from this instance. It is therefore necessary to re-register views each time the ads loader is reused. Alternatively, provide overlay views via the AdViewProvider when creating the media source to benefit from automatic registration.
-
public void requestAds([DataSpec](../../upstream/DataSpec.html "class in com.google.android.exoplayer2.upstream")adTagDataSpec,[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")adsId,
@Nullable[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html "class or interface in android.view")adViewGroup)
Deprecated.
Requests ads, if they have not already been requested. Must be called on the main thread.
Ads will be requested automatically when the player is prepared if this method has not been called, so it is only necessary to call this method if you want to request ads before preparing the player.
Parameters:adTagDataSpec - The data specification of the ad tag to load. See class javadoc for information about compatible ad tag formats.adsId - A opaque identifier for the ad playback state across start/stop calls.adViewGroup - A ViewGroup on top of the player that will show any ad UI, or null if playing audio-only ads.
-
public void skipAd()
Deprecated.
Skips the current ad.
This method is intended for apps that play audio-only ads and so need to provide their own UI for users to skip skippable ads. Apps showing video ads should not call this method, as the IMA SDK provides the UI to skip ads in the ad view group passed via AdViewProvider.
-
public void focusSkipButton()
Deprecated.
Moves UI focus to the skip button (or other interactive elements), if currently shown. See BaseManager.focus().
-
public void setPlayer(@Nullable[Player](../../Player.html "interface in com.google.android.exoplayer2")player)
Deprecated.
Description copied from interface: AdsLoader
Sets the player that will play the loaded ads.
This method must be called before the player is prepared with media using this ads loader.
This method must also be called on the main thread and only players which are accessed on the main thread are supported (player.getApplicationLooper() == Looper.getMainLooper()).
Specified by:setPlayer in interface AdsLoaderParameters:player - The player instance that will play the loaded ads. May be null to delete the reference to a previously set player.
-
public void setSupportedContentTypes([@ContentType](../../C.ContentType.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.C.ContentType int... contentTypes)
Deprecated.
Description copied from interface: AdsLoader
Sets the supported content types for ad media. Must be called before the first call to AdsLoader.start(AdsMediaSource, DataSpec, Object, AdViewProvider, EventListener). Subsequent calls may be ignored. Called on the main thread by AdsMediaSource.
Specified by:setSupportedContentTypes in interface AdsLoaderParameters:contentTypes - The supported content types for ad media. Each element must be one of C.CONTENT_TYPE_DASH, C.CONTENT_TYPE_HLS, C.CONTENT_TYPE_SS and C.CONTENT_TYPE_OTHER.
-
public void start([AdsMediaSource](../../source/ads/AdsMediaSource.html "class in com.google.android.exoplayer2.source.ads")adsMediaSource,[DataSpec](../../upstream/DataSpec.html "class in com.google.android.exoplayer2.upstream")adTagDataSpec,[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")adsId,[AdViewProvider](../../ui/AdViewProvider.html "interface in com.google.android.exoplayer2.ui")adViewProvider,[AdsLoader.EventListener](../../source/ads/AdsLoader.EventListener.html "interface in com.google.android.exoplayer2.source.ads")eventListener)
Deprecated.
Description copied from interface: AdsLoader
Starts using the ads loader for playback. Called on the main thread by AdsMediaSource.
Specified by:start in interface AdsLoaderParameters:adsMediaSource - The ads media source requesting to start loading ads.adTagDataSpec - A data spec for the ad tag to load.adsId - An opaque identifier for the ad playback state across start/stop calls.adViewProvider - Provider of views for the ad UI.eventListener - Listener for ads loader events.
-
public void stop([AdsMediaSource](../../source/ads/AdsMediaSource.html "class in com.google.android.exoplayer2.source.ads")adsMediaSource,[AdsLoader.EventListener](../../source/ads/AdsLoader.EventListener.html "interface in com.google.android.exoplayer2.source.ads")eventListener)
Deprecated.
Description copied from interface: AdsLoader
Stops using the ads loader for playback and deregisters the event listener. Called on the main thread by AdsMediaSource.
Specified by:stop in interface AdsLoaderParameters:adsMediaSource - The ads media source requesting to stop loading/playing ads.eventListener - The ads media source's listener for ads loader events.
-
public void release()
Deprecated.
Description copied from interface: AdsLoader
Releases the loader. Must be called by the application on the main thread when the instance is no longer needed.
Specified by:release in interface AdsLoader
-
public void handlePrepareComplete([AdsMediaSource](../../source/ads/AdsMediaSource.html "class in com.google.android.exoplayer2.source.ads")adsMediaSource,
int adGroupIndex,
int adIndexInAdGroup)
Deprecated.
Description copied from interface: AdsLoader
Notifies the ads loader that preparation of an ad media period is complete. Called on the main thread by AdsMediaSource.
Specified by:handlePrepareComplete in interface AdsLoaderParameters:adsMediaSource - The ads media source for which preparation of ad media completed.adGroupIndex - The index of the ad group.adIndexInAdGroup - The index of the ad in the ad group.
-
public void handlePrepareError([AdsMediaSource](../../source/ads/AdsMediaSource.html "class in com.google.android.exoplayer2.source.ads")adsMediaSource,
int adGroupIndex,
int adIndexInAdGroup,[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")exception)
Deprecated.
Description copied from interface: AdsLoader
Notifies the ads loader that the player was not able to prepare media for a given ad. Implementations should update the ad playback state as the specified ad has failed to load. Called on the main thread by AdsMediaSource.
Specified by:handlePrepareError in interface AdsLoaderParameters:adsMediaSource - The ads media source for which preparation of ad media failed.adGroupIndex - The index of the ad group.adIndexInAdGroup - The index of the ad in the ad group.exception - The preparation error.