Class InstreamAudioAd
-
- All Implemented Interfaces:
public final class InstreamAudioAd extends BaseAd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classInstreamAudioAd.AudioSectionInfoModel for audio section info
public final classInstreamAudioAd.InstreamAdCompanionBannerModel for companion banner. Usually this is clickable additional image or web element which should be shown in context of audio ads
public final classInstreamAudioAd.InstreamAudioAdBannerModel for InStream audio banner
public interfaceInstreamAudioAd.InstreamAudioAdListener
-
Constructor Summary
Constructors Constructor Description InstreamAudioAd(int slotId, Context context)Public constructor InstreamAudioAd(int slotId, MenuFactory adChoicesMenuFactory, Context context)Public constructor InstreamAudioAd(String json, Context context)Public constructor InstreamAudioAd(String json, MenuFactory adChoicesMenuFactory, Context context)Public constructor
-
Method Summary
Modifier and Type Method Description voidconfigureMidpoints(float audioDuration)Sets the duration of the main audio. voidconfigureMidpoints(float audioDuration, @Nullable() Array<float> midpoints)Sets the duration of the main audio. voidconfigureMidpointsPercents(float audioDuration, @Nullable() Array<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 resources List<String>getAudioSectionNames()Audio section is sequence of audios based on position inside audio. InstreamAudioAd.InstreamAudioAdBannergetCurrentBanner()Current playing banner available only after start playing and receiving InstreamAudioAdListener.onBannerStart(InstreamAudioAd, InstreamAudioAdBanner) callback InstreamAudioAd.InstreamAudioAdListenergetListener()Get events listener of an advertisement intgetLoadingTimeout()Array<float>getMidPoints()Method for getting a list of points at which audio banners will be played. InstreamAudioAdPlayergetPlayer()Player was set to play audio ad. InstreamAudioAd.AudioSectionInfogetPrerollSectionInfo()Returns preroll section info. floatgetVolume()voidhandleAdChoicesClick(@NonNull() Context context)Call to display adChoices voidhandleClick()This should be called when user clicks on ad call-to-action element. voidhandleCompanionClick(@NonNull() InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner)Opens companion's tracking link and click statistics with default app context. voidhandleCompanionClick(@NonNull() InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner, @NonNull() Context context)Opens companion's tracking link and click statistics with context voidhandleCompanionShow(@NonNull() InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner)Calls show/impression statistics from companion banner voidload()Start loading ads. voidpause()Pauses ad audio voidresume()Resumes ad audio from pause voidsetListener(@Nullable() InstreamAudioAd.InstreamAudioAdListener listener)Set events listener of an advertisement Must be called before InstreamAudioAd.load() voidsetLoadingTimeout(int loadingTimeout)An Ad loading timeout can be set before loading ad. voidsetPlayer(@Nullable() InstreamAudioAdPlayer player)Sets custom implementation of InstreamAudioAdPlayer. 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. voidskipBanner()Explicitly ends playing current audio banner. voidstartMidroll(float point)Starts the "midroll" section of audio ad at point.voidstartPauseroll()Starts the "pauseroll" section of audio ad voidstartPostroll()Starts the "postroll" section of audio ad voidstartPreroll()Starts the "preroll" section of audio ad voidstop()Stops ad audio -
-
Constructor Detail
-
InstreamAudioAd
InstreamAudioAd(int slotId, Context context)
Public constructor- Parameters:
slotId- your slot idcontext- app context
-
InstreamAudioAd
InstreamAudioAd(int slotId, MenuFactory adChoicesMenuFactory, Context context)
Public constructor- Parameters:
slotId- your slot idadChoicesMenuFactory- adChoice rendering factorycontext- app context
-
InstreamAudioAd
InstreamAudioAd(String json, Context context)
Public constructor- Parameters:
json- your json-contentcontext- app context
-
InstreamAudioAd
InstreamAudioAd(String json, MenuFactory adChoicesMenuFactory, Context context)
Public constructor- Parameters:
json- your json-contentadChoicesMenuFactory- adChoice rendering factorycontext- app context
-
-
Method Detail
-
configureMidpoints
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
void configureMidpoints(float audioDuration, @Nullable() Array<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
void configureMidpointsPercents(float audioDuration, @Nullable() Array<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
-
destroy
void destroy()
Destroys the ad and frees resources
-
getAudioSectionNames
@NonNull() List<String> getAudioSectionNames()
Audio section is sequence of audios based on position inside audio. There are "preroll", "postroll", "midroll", "pauseroll". For example, if Ad has only "preroll" section name, there are some banners in preroll section, and they will start when InstreamAudioAd.startPreroll() called, and nothing will happen if InstreamAudioAd.startPostroll() called. Ad can contain one or multiple audio sections to play. This method represents available sections for this ad.
- Returns:
list of available audio section names
-
getCurrentBanner
@Nullable() InstreamAudioAd.InstreamAudioAdBanner getCurrentBanner()
Current playing banner available only after start playing and receiving InstreamAudioAdListener.onBannerStart(InstreamAudioAd, InstreamAudioAdBanner) callback
- Returns:
current playing banner
-
getListener
@Nullable() InstreamAudioAd.InstreamAudioAdListener getListener()
Get events listener of an advertisement
- Returns:
an instance of listener
-
getLoadingTimeout
int getLoadingTimeout()
- Returns:
loading timeout for this Ad
-
getMidPoints
@NonNull() Array<float> getMidPoints()
Method for getting a list of points at which audio banners will be played. Should be called after calling one of the InstreamAudioAd.configureMidpoints(float), or InstreamAudioAd.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
-
getPlayer
@Nullable() 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
-
getPrerollSectionInfo
@Nullable() InstreamAudioAd.AudioSectionInfo getPrerollSectionInfo()
Returns preroll section info.
Returns
nullif audio ad is not loaded yet, or where were errors while loading.
-
getVolume
float getVolume()
- Returns:
volume param
-
handleAdChoicesClick
void handleAdChoicesClick(@NonNull() Context context)
Call to display adChoices
-
handleClick
void handleClick()
This should be called when user clicks on ad call-to-action element. Goes to the ad placement according banner logic and calls click statistics
-
handleCompanionClick
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 InstreamAudioAd.handleCompanionClick(InstreamAdCompanionBanner, Context)
- Parameters:
instreamAdCompanionBanner- clicked companion
-
handleCompanionClick
void handleCompanionClick(@NonNull() InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner, @NonNull() Context context)
Opens companion's tracking link and click statistics with context
- Parameters:
instreamAdCompanionBanner- clicked companioncontext- context to handle intent
-
handleCompanionShow
void handleCompanionShow(@NonNull() InstreamAudioAd.InstreamAdCompanionBanner instreamAdCompanionBanner)
Calls show/impression statistics from companion banner
- Parameters:
instreamAdCompanionBanner- showing companion
-
load
void load()
Start loading ads. In case of successful loading, the 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 InstreamAudioAdListener.onNoAd(IAdLoadingError, InstreamAudioAd) Listener must be added before loading
-
pause
void pause()
Pauses ad audio
-
resume
void resume()
Resumes ad audio from pause
-
setListener
void setListener(@Nullable() InstreamAudioAd.InstreamAudioAdListener listener)
Set events listener of an advertisement Must be called before InstreamAudioAd.load()
-
setLoadingTimeout
void setLoadingTimeout(int loadingTimeout)
An Ad loading timeout can be set before loading ad. When timeout passes without any callbacks, 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
-
setPlayer
void setPlayer(@Nullable() InstreamAudioAdPlayer player)
Sets custom implementation of InstreamAudioAdPlayer. Before playing, it must be set player here.
- Parameters:
player- custom player implementation
-
setVolume
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]
-
skip
void skip()
Explicitly ends playing current section/sequence of ad audios.
-
skipBanner
void skipBanner()
Explicitly ends playing current audio banner. Starts next banner then, if exists, or finishes playing audio ads section
-
startMidroll
void startMidroll(float point)
Starts the "midroll" section of audio ad at
point. An array of available midroll points can be get InstreamAudioAd.getMidPoints().InstreamAudioAdPlayermust be set before calling this function via InstreamAudioAd.setPlayer(InstreamAudioAdPlayer).
-
startPauseroll
void startPauseroll()
Starts the "pauseroll" section of audio ad
-
startPostroll
void startPostroll()
Starts the "postroll" section of audio ad
-
startPreroll
void startPreroll()
Starts the "preroll" section of audio ad
-
stop
void stop()
Stops ad audio
-
-
-
-