Class YandexAdsLoader

  • 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 Type Field Description
      static java.lang.String AD_TAG_URI  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void handlePrepareComplete​(com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource, int adGroupIndex, int adIndexInAdGroup)  
      void handlePrepareError​(com.google.android.exoplayer2.source.ads.AdsMediaSource adsMediaSource, int adGroupIndex, int adIndexInAdGroup, java.io.IOException exception)  
      void release()  
      void requestAds​(android.view.ViewGroup adViewGroup)
      Requests ads, if they have not already been requested.
      void setPlayer​(com.google.android.exoplayer2.Player player)  
      void setSupportedContentTypes​(int... contentTypes)  
      void setVideoAdPlaybackListener​(com.yandex.mobile.ads.video.playback.VideoAdPlaybackListener listener)
      Sets listener for single video ad creative playback events.
      void start​(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)  
      void stop​(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
    • 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​(@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