Package com.my.target.instreamads
Class InstreamAudioAd
java.lang.Object
com.my.target.common.BaseAd
com.my.target.instreamads.InstreamAudioAd
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classModel for companion banner.static final classModel for InStream audio bannerstatic interface -
Field Summary
Fields inherited from class com.my.target.common.BaseAd
adConfig, metricFactory -
Constructor Summary
ConstructorsConstructorDescriptionInstreamAudioAd(int slotId, android.content.Context context) Public constructorInstreamAudioAd(int slotId, MenuFactory adChoicesMenuFactory, android.content.Context context) Public constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigureMidpoints(float audioDuration) Sets the duration of the main audio.voidconfigureMidpoints(float audioDuration, float[] midpoints) Sets the duration of the main audio.voidconfigureMidpointsPercents(float audioDuration, float[] midpointsPercents) Allows you to set the duration of the main audio in seconds and an array of banner midroll points in percent.voiddestroy()Destroys the ad and frees resourcesCurrent playing banner available only after start playing and receivingInstreamAudioAd.InstreamAudioAdListener.onBannerStart(InstreamAudioAd, InstreamAudioAdBanner)callbackGet events listener of an advertisementintfloat[]Method for getting a list of points at which audio banners will be played.Player was set to play audio ad.floatvoidhandleAdChoicesClick(android.content.Context context) Call to display adChoicesvoidhandleCompanionClick(InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner) Opens companion's tracking link and click statistics with default app context.voidhandleCompanionClick(InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner, android.content.Context context) Opens companion's tracking link and click statistics with contextvoidhandleCompanionShow(InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner) Calls show/impression statistics from companion bannervoidload()Start loading ads.voidpause()Pauses ad audiovoidresume()Resumes ad audio from pausevoidSet events listener of an advertisement Must be called beforeload()voidsetLoadingTimeout(int loadingTimeout) An Ad loading timeout can be set before loading ad.voidsetPlayer(InstreamAudioAdPlayer player) Sets custom implementation ofInstreamAudioAdPlayer.voidsetVolume(float volume) Allows you to control the volume of audio playback and affects the sending of statistics of sound changes.voidskip()Explicitly ends playing current section/sequence of ad audios.voidExplicitly ends playing current audio banner.voidstartMidroll(float point) Starts the "midroll" section of audio ad at point.voidStarts the "pauseroll" section of audio advoidStarts the "postroll" section of audio advoidStarts the "preroll" section of audio advoidstop()Stops ad audioMethods inherited from class com.my.target.common.BaseAd
getCustomParams, isLoadCalled, setAdNetworkConfig
-
Constructor Details
-
InstreamAudioAd
public InstreamAudioAd(int slotId, @NonNull android.content.Context context) Public constructor- Parameters:
slotId- your slot idcontext- app context
-
-
Method Details
-
getListener
Get events listener of an advertisement- Returns:
- an instance of listener
- See Also:
-
setListener
Set events listener of an advertisement Must be called beforeload()- 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
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
Sets custom implementation ofInstreamAudioAdPlayer. 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 theconfigureMidpoints(float), orconfigureMidpointsPercents(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
Current playing banner available only after start playing and receivingInstreamAudioAd.InstreamAudioAdListener.onBannerStart(InstreamAudioAd, InstreamAudioAdBanner)callback- Returns:
- current playing banner
-
load
public void load()Start loading ads. In case of successful loading, theInstreamAudioAd.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 - theInstreamAudioAd.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 midpointsmidpoints- 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 midpointsmidpointsPercents- 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 getgetMidPoints() -
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, usehandleCompanionClick(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 companioncontext- 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
-