All Implemented Interfaces:
com.google.android.exoplayer2.source.ads.AdsLoader


public class YandexAdsLoader
extends java.lang.Object
implements com.google.android.exoplayer2.source.ads.AdsLoader
This class is implementation of ExoPlayer's AdsLoader interface. It can be used for simplified integration of Yandex Instream Ads to Exoplayer. Note that all methods of this class must be called on main thread.

Nested Class Summary

Nested classes/interfaces inherited from interface com.google.android.exoplayer2.source.ads.AdsLoader

com.google.android.exoplayer2.source.ads.AdsLoader.EventListener

Field Summary

Fields
Modifier and TypeField and Description
static java.lang.StringAD_TAG_URI 

Constructor Summary

Constructors
Constructor and Description
YandexAdsLoader(android.content.Context context, InstreamAdRequestConfiguration requestConfiguration) 

Method Summary

All Methods
Instance Methods
Concrete Methods
Modifier and TypeMethod and Description
voidhandlePrepareComplete(com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource, int adGroupIndex, int adIndexInAdGroup) 
voidhandlePrepareError(com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource, int adGroupIndex, int adIndexInAdGroup, java.io.IOException exception) 
voidrelease() 
voidrequestAds(android.view.ViewGroup adViewGroup)
Requests ads, if they have not already been requested.
voidsetPlayer(com.google.android.exoplayer2.Player player) 
voidsetSupportedContentTypes(int... contentTypes) 
voidsetVideoAdPlaybackListener(com.yandex.mobile.ads.video.playback.VideoAdPlaybackListener listener)
Sets listener for single video ad creative playback events.
voidstart(com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource, com.google.android.exoplayer2.upstream.DataSpec adTagDataSpec, java.lang.Object adPlaybackId, com.google.android.exoplayer2.ui.AdViewProvider adViewProvider, com.google.android.exoplayer2.source.ads.AdsLoader.EventListener eventListener) 
voidstop(com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource, com.google.android.exoplayer2.source.ads.AdsLoader.EventListener eventListener) 

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

AD_TAG_URI

public static final java.lang.String AD_TAG_URI
See Also:
Constant Field Values

Constructor Detail

YandexAdsLoader

public YandexAdsLoader(@NonNull
                       android.content.Context context,
                       @NonNull
                       InstreamAdRequestConfiguration requestConfiguration)

Method Detail

requestAds

public void requestAds(@Nullable
                       android.view.ViewGroup adViewGroup)
Requests ads, if they have not already been requested. 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:
adViewGroup - A ViewGroup on top of the player that will show any ad UI.

setVideoAdPlaybackListener

public void setVideoAdPlaybackListener(@Nullable
                                       com.yandex.mobile.ads.video.playback.VideoAdPlaybackListener listener)
Sets listener for single video ad creative playback events.
Parameters:
listener - A VideoAdPlaybackListener that will be triggered on video events.

setPlayer

public void setPlayer(@Nullable
                      com.google.android.exoplayer2.Player player)
Specified by:
setPlayer in interface com.google.android.exoplayer2.source.ads.AdsLoader

release

public void release()
Specified by:
release in interface com.google.android.exoplayer2.source.ads.AdsLoader

setSupportedContentTypes

public void setSupportedContentTypes(@C.ContentType
                                     int... contentTypes)
Specified by:
setSupportedContentTypes in interface com.google.android.exoplayer2.source.ads.AdsLoader

start

public void start(@Nullable
                  com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource,
                  @Nullable
                  com.google.android.exoplayer2.upstream.DataSpec adTagDataSpec,
                  @Nullable
                  java.lang.Object adPlaybackId,
                  @Nullable
                  com.google.android.exoplayer2.ui.AdViewProvider adViewProvider,
                  @Nullable
                  com.google.android.exoplayer2.source.ads.AdsLoader.EventListener eventListener)
Specified by:
start in interface com.google.android.exoplayer2.source.ads.AdsLoader

stop

public void stop(@Nullable
                 com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource,
                 @Nullable
                 com.google.android.exoplayer2.source.ads.AdsLoader.EventListener eventListener)
Specified by:
stop in interface com.google.android.exoplayer2.source.ads.AdsLoader

handlePrepareComplete

public void handlePrepareComplete(@Nullable
                                  com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource,
                                  int adGroupIndex,
                                  int adIndexInAdGroup)
Specified by:
handlePrepareComplete in interface com.google.android.exoplayer2.source.ads.AdsLoader

handlePrepareError

public void handlePrepareError(@Nullable
                               com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource,
                               int adGroupIndex,
                               int adIndexInAdGroup,
                               @Nullable
                               java.io.IOException exception)
Specified by:
handlePrepareError in interface com.google.android.exoplayer2.source.ads.AdsLoader