Class InstreamAudioAd

java.lang.Object
com.my.target.common.BaseAd
com.my.target.instreamads.InstreamAudioAd

public final class InstreamAudioAd extends BaseAd
  • Constructor Details

    • InstreamAudioAd

      public InstreamAudioAd(int slotId, @NonNull android.content.Context context)
      Public constructor
      Parameters:
      slotId - your slot id
      context - app context
    • InstreamAudioAd

      public InstreamAudioAd(int slotId, @NonNull MenuFactory adChoicesMenuFactory, @NonNull android.content.Context context)
      Public constructor
      Parameters:
      slotId - your slot id
      adChoicesMenuFactory - adChoice rendering factory
      context - app context
  • Method Details

    • getListener

      @Nullable public InstreamAudioAd.InstreamAudioAdListener getListener()
      Get events listener of an advertisement
      Returns:
      an instance of listener
      See Also:
    • setListener

      public void setListener(@Nullable InstreamAudioAd.InstreamAudioAdListener listener)
      Set events listener of an advertisement Must be called before load()
      See Also:
    • getLoadingTimeout

      public int getLoadingTimeout()
      Returns:
      loading timeout for this Ad
      See Also:
    • setLoadingTimeout

      public void setLoadingTimeout(int loadingTimeout)
      An Ad loading timeout can be set before loading ad. When timeout passes without any callbacks, InstreamAudioAd.InstreamAudioAdListener.onNoAd(IAdLoadingError, InstreamAudioAd) will be called. Default value is 10 seconds, minimum 5 seconds. If value less than 5 seconds set, it will be 5 seconds.
      Parameters:
      loadingTimeout - desired timeout in seconds
    • getPlayer

      @Nullable public InstreamAudioAdPlayer getPlayer()
      Player was set to play audio ad. If no player was set, method will return null
      Returns:
      player for ad audio playing. Default null
      See Also:
    • setPlayer

      public void setPlayer(@Nullable InstreamAudioAdPlayer player)
      Sets custom implementation of InstreamAudioAdPlayer. Before playing, it must be set player here.
      Parameters:
      player - custom player implementation
      See Also:
    • getVolume

      public float getVolume()
      Returns:
      volume param
      See Also:
    • setVolume

      public void setVolume(float volume)
      Allows you to control the volume of audio playback and affects the sending of statistics of sound changes. When the application uses its own implementation of the player, the correct way to control the volume of the Ad is to change this property. Accepts a range of values [0-1], where 1 is max volume and 0 is mute
      Parameters:
      volume - volume param in range [0,1]
    • getMidPoints

      @NonNull public float[] getMidPoints()
      Method for getting a list of points at which audio banners will be played. Should be called after calling one of the configureMidpoints(float), or configureMidpointsPercents(float, float[]) methods to get an array of points based on the duration of the main audio and points set by the application.
      Returns:
      array of midroll points available
    • getCurrentBanner

      @Nullable public InstreamAudioAd.InstreamAudioAdBanner getCurrentBanner()
      Current playing banner available only after start playing and receiving InstreamAudioAd.InstreamAudioAdListener.onBannerStart(InstreamAudioAd, InstreamAudioAdBanner) callback
      Returns:
      current playing banner
    • load

      public void load()
      Start loading ads. In case of successful loading, the InstreamAudioAd.InstreamAudioAdListener.onLoad(InstreamAudioAd) method will be called on the object passed as a listener, in case of loading error or if there is no advertisement to be shown - the InstreamAudioAd.InstreamAudioAdListener.onNoAd(IAdLoadingError, InstreamAudioAd) Listener must be added before loading
      See Also:
    • configureMidpoints

      public void configureMidpoints(float audioDuration)
      Sets the duration of the main audio. When using this method, the points for playing the banners will be resolved automatically.
      Parameters:
      audioDuration - duration of the audio, where should be midpoints
    • configureMidpoints

      public void configureMidpoints(float audioDuration, @Nullable float[] midpoints)
      Sets the duration of the main audio. Points will be resolved as much as possible close to the desired midpoints array
      Parameters:
      audioDuration - duration of the audio, where should be midpoints
      midpoints - an array with desired positions
    • configureMidpointsPercents

      public void configureMidpointsPercents(float audioDuration, @Nullable float[] midpointsPercents)
      Allows you to set the duration of the main audio in seconds and an array of banner midroll points in percent.
      Parameters:
      audioDuration - duration of the audio, where should be midpoints
      midpointsPercents - an array with desired positions in percents
    • pause

      public void pause()
      Pauses ad audio
    • resume

      public void resume()
      Resumes ad audio from pause
    • stop

      public void stop()
      Stops ad audio
    • skip

      public void skip()
      Explicitly ends playing current section/sequence of ad audios.
    • skipBanner

      public void skipBanner()
      Explicitly ends playing current audio banner. Starts next banner then, if exists, or finishes playing audio ads section
    • destroy

      public void destroy()
      Destroys the ad and frees resources
    • startPreroll

      public void startPreroll()
      Starts the "preroll" section of audio ad
    • startPostroll

      public void startPostroll()
      Starts the "postroll" section of audio ad
    • startPauseroll

      public void startPauseroll()
      Starts the "pauseroll" section of audio ad
    • startMidroll

      public void startMidroll(float point)
      Starts the "midroll" section of audio ad at point. An array of available midroll points can be get getMidPoints()
    • handleCompanionClick

      public void handleCompanionClick(@NonNull InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner)
      Opens companion's tracking link and click statistics with default app context. In most cases application context will be used, so if it is needed to run with activity context, use handleCompanionClick(InstreamAdCompanionBanner, Context)
      Parameters:
      instreamAdCompanionBanner - clicked companion
      See Also:
    • handleCompanionClick

      public void handleCompanionClick(@NonNull InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner, @NonNull android.content.Context context)
      Opens companion's tracking link and click statistics with context
      Parameters:
      instreamAdCompanionBanner - clicked companion
      context - context to handle intent
      See Also:
    • handleCompanionShow

      public void handleCompanionShow(@NonNull InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner)
      Calls show/impression statistics from companion banner
      Parameters:
      instreamAdCompanionBanner - showing companion
      See Also:
    • handleAdChoicesClick

      public void handleAdChoicesClick(@NonNull android.content.Context context)
      Call to display adChoices