AFCImaAdsLoader

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. 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 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 getDataUriForString.

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.

Types

Link copied to clipboard
class Builder
Builder for AFCImaAdsLoader.

Functions

Link copied to clipboard
Moves UI focus to the skip button (or other interactive elements), if currently shown.
Link copied to clipboard
open fun getAdDisplayContainer(): AdDisplayContainer
Returns the AdDisplayContainer used by this loader, or null if ads have not been requested yet.
Link copied to clipboard
open fun getAdsLoader(): AdsLoader
Returns the underlying com.google.ads.interactivemedia.v3.api.AdsLoader wrapped by this instance, or null if ads have not been requested yet.
Link copied to clipboard
open fun handleContentTimelineChanged(adsMediaSource: AdsMediaSource, timeline: Timeline): Boolean
Link copied to clipboard
open fun handlePrepareComplete(adsMediaSource: AdsMediaSource, adGroupIndex: Int, adIndexInAdGroup: Int)
Link copied to clipboard
open fun handlePrepareError(adsMediaSource: AdsMediaSource, adGroupIndex: Int, adIndexInAdGroup: Int, exception: IOException)
Link copied to clipboard
open fun release()
Link copied to clipboard
open fun requestAds(adTagDataSpec: DataSpec, adsId: Any, @Nullable adViewGroup: ViewGroup)
Requests ads, if they have not already been requested.
Link copied to clipboard
open fun setPlayer(@Nullable player: Player)
Link copied to clipboard
Link copied to clipboard
open fun skipAd()
Skips the current ad.
Link copied to clipboard
open fun start(adsMediaSource: AdsMediaSource, adTagDataSpec: DataSpec, adsId: Any, adViewProvider: AdViewProvider, eventListener: AdsLoader.EventListener)
Link copied to clipboard
open fun stop(adsMediaSource: AdsMediaSource, eventListener: AdsLoader.EventListener)