Class InstreamAd
-
- All Implemented Interfaces:
public final class InstreamAd extends BaseAd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classInstreamAd.InstreamAdBannerModel for InStream banner
public final classInstreamAd.InstreamAdCompanionBannerModel for InStream video motion banner
public interfaceInstreamAd.InstreamAdListenerpublic final classInstreamAd.InstreamAdVideoMotionBannerpublic interfaceInstreamAd.SectionPrepareCallback
-
Constructor Summary
Constructors Constructor Description InstreamAd(int slotId, Context context)Public constructor InstreamAd(int slotId, MenuFactory adChoicesMenuFactory, Context context)Public constructor InstreamAd(String json, Context context)Public constructor InstreamAd(String json, MenuFactory adChoicesMenuFactory, Context context)Public constructor
-
Method Summary
Modifier and Type Method Description voidconfigureMidpoints(float videoDuration)Sets the duration of the main video. voidconfigureMidpoints(float videoDuration, @Nullable() Array<float> midpoints)Sets the duration of the main video. voidconfigureMidpointsPercents(float videoDuration, @Nullable() Array<float> midpointsPercents)Allows you to set the duration of the main video in seconds and an array of banner midroll points in percent. voiddestroy()Destroys the ad and frees resources InstreamAd.InstreamAdListenergetListener()Get events listener of an advertisement intgetLoadingTimeout()Array<float>getMidPoints()Method for getting a list of points at which video banners will be played. InstreamAdPlayergetPlayer()Player was set to play video ad. ViewgetShoppableView(@NonNull() Context context)Get the web view with shoppable ad that contains in companion intgetVideoQuality()Gets desired video quality of loading video. List<String>getVideoSectionNames()Video section is sequence of videos based on position inside video. 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() InstreamAd.InstreamAdCompanionBanner instreamAdCompanionBanner)Opens companion's tracking link and click statistics with default app context. voidhandleCompanionClick(@NonNull() InstreamAd.InstreamAdCompanionBanner instreamAdCompanionBanner, @NonNull() Context context)Opens companion's tracking link and click statistics with context voidhandleCompanionShow(@NonNull() InstreamAd.InstreamAdCompanionBanner instreamAdCompanionBanner)Calls show/impression statistics from companion banner booleanisFullscreen()booleanisShoppablePresented()voidload()Start loading ads. voidpause()Pauses ad video voidprepareMidroll(float point, @NonNull() InstreamAd.SectionPrepareCallback sectionPrepareCallback)Initiate prepare for the "midroll" section of video ad at point.voidpreparePauseroll(@NonNull() InstreamAd.SectionPrepareCallback sectionPrepareCallback)Initiate prepare for the "pauseroll" section of video ad. voidpreparePostroll(@NonNull() InstreamAd.SectionPrepareCallback sectionPrepareCallback)Initiate prepare for the "postroll" section of video ad. voidresume()Resumes ad video from pause voidsetFullscreen(boolean fullscreen)The fullscreen property is intended to inform the InstreamAd component about changing the video playback mode to fullscreen and back. voidsetListener(@Nullable() InstreamAd.InstreamAdListener listener)Set events listener of an advertisement Must be called before InstreamAd.load() voidsetLoadingTimeout(int loadingTimeout)An Ad loading timeout can be set before loading ad. voidsetPlayer(@Nullable() InstreamAdPlayer player)Sets custom implementation of InstreamAdPlayer. voidsetPostViewPlayer(@Nullable() InstreamAdPostViewPlayer postViewPlayer)Sets implementation of InstreamAdPostViewPlayer. voidsetQrCtaPlayer(@Nullable() QrCtaPlayer qrCtaPlayer)* Sets implementation of QrCtaPlayer. voidsetShoppablePresented(boolean isPresented)The fullscreen property is intended to inform the InstreamAd component about showing shoppable ad while playing video or not. voidsetVideoMotionPlayer(@Nullable() InstreamAdVideoMotionPlayer instreamAdVideoMotionPlayer)voidsetVideoQuality(int videoQuality)Desired video quality can be set. voidsetVolume(float volume)Allows you to control the volume of video playback and affects the sending of statistics of sound changes. voidshoppableAdsItemClick(@NonNull() String shoppableAdsItemId)Must be called when the rendered ShoppableAdsItem has been clicked. voidshoppableAdsItemShow(@NonNull() String shoppableAdsItemId)Should be called when you have rendered the ShoppableAdsItem voidskip()Explicitly ends playing current section/sequence of ad videos. voidskipBanner()Explicitly ends playing current video banner. voidstartMidroll(float point)Starts the "midroll" section of video ad at point.voidstartPauseroll()Starts the "pauseroll" section of video ad voidstartPostroll()Starts the "postroll" section of video ad voidstartPreroll()Starts the "preroll" section of video ad voidstop()Stops ad video voidswapPlayer(@Nullable() InstreamAdPlayer player)Swaps player to another with saving it's state. voiduseDefaultPlayer()Sets the default player to play video ads. voiduseDefaultPlayer(boolean useExoPlayer)Sets the default player to play video ads. -
-
Constructor Detail
-
InstreamAd
InstreamAd(int slotId, Context context)
Public constructor- Parameters:
slotId- your slot idcontext- app context
-
InstreamAd
InstreamAd(int slotId, MenuFactory adChoicesMenuFactory, Context context)
Public constructor- Parameters:
slotId- your slot idadChoicesMenuFactory- adChoice rendering factorycontext- app context
-
InstreamAd
InstreamAd(String json, Context context)
Public constructor- Parameters:
json- your json-contentcontext- app context
-
InstreamAd
InstreamAd(String json, MenuFactory adChoicesMenuFactory, Context context)
Public constructor- Parameters:
json- your json-contentadChoicesMenuFactory- adChoice rendering factorycontext- app context
-
-
Method Detail
-
configureMidpoints
void configureMidpoints(float videoDuration)
Sets the duration of the main video. When using this method, the points for playing the banners will be resolved automatically.
- Parameters:
videoDuration- duration of the video, where should be midpoints
-
configureMidpoints
void configureMidpoints(float videoDuration, @Nullable() Array<float> midpoints)
Sets the duration of the main video. Points will be resolved as much as possible close to the desired midpoints array
- Parameters:
videoDuration- duration of the video, where should be midpointsmidpoints- an array with desired positions
-
configureMidpointsPercents
void configureMidpointsPercents(float videoDuration, @Nullable() Array<float> midpointsPercents)
Allows you to set the duration of the main video in seconds and an array of banner midroll points in percent.
- Parameters:
videoDuration- duration of the video, where should be midpointsmidpointsPercents- an array with desired positions in percents
-
destroy
void destroy()
Destroys the ad and frees resources
-
getListener
@Nullable() InstreamAd.InstreamAdListener 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 video banners will be played. Should be called after calling one of the InstreamAd.configureMidpoints(float), or InstreamAd.configureMidpointsPercents(float, float[]) methods to get an array of points based on the duration of the main video and points set by the application.
- Returns:
array of midroll points available
-
getPlayer
@Nullable() InstreamAdPlayer getPlayer()
Player was set to play video ad. If no player was set, method will return null
- Returns:
player for ad video playing. Null if default set
-
getShoppableView
@Nullable() View getShoppableView(@NonNull() Context context)
Get the web view with shoppable ad that contains in companion
-
getVideoQuality
int getVideoQuality()
Gets desired video quality of loading video. In vertical pixels.
- Returns:
video
-
getVideoSectionNames
@NonNull() List<String> getVideoSectionNames()
Video section is sequence of videos based on position inside video. 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 InstreamAd.startPreroll() called, and nothing will happen if InstreamAd.startPostroll() called. Ad can contain one or multiple video sections to play. This method represents available sections for this ad.
- Returns:
list of available video section names
-
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() InstreamAd.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 InstreamAd.handleCompanionClick(InstreamAdCompanionBanner, Context)
- Parameters:
instreamAdCompanionBanner- clicked companion
-
handleCompanionClick
void handleCompanionClick(@NonNull() InstreamAd.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() InstreamAd.InstreamAdCompanionBanner instreamAdCompanionBanner)
Calls show/impression statistics from companion banner
- Parameters:
instreamAdCompanionBanner- showing companion
-
isFullscreen
boolean isFullscreen()
- Returns:
param is ad in fullscreen mode or not
-
isShoppablePresented
boolean isShoppablePresented()
- Returns:
param is shoppable ad presented or not
-
load
void load()
Start loading ads. In case of successful loading, the InstreamAdListener.onLoad(InstreamAd) 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 InstreamAdListener.onNoAd(IAdLoadingError, InstreamAd) Listener must be added before loading
-
pause
void pause()
Pauses ad video
-
prepareMidroll
void prepareMidroll(float point, @NonNull() InstreamAd.SectionPrepareCallback sectionPrepareCallback)
Initiate prepare for the "midroll" section of video ad at
point. An array of available midroll points can be get InstreamAd.getMidPoints().- Parameters:
sectionPrepareCallback- SDK will call this callback after prepare is completed.
-
preparePauseroll
void preparePauseroll(@NonNull() InstreamAd.SectionPrepareCallback sectionPrepareCallback)
Initiate prepare for the "pauseroll" section of video ad.
- Parameters:
sectionPrepareCallback- SDK will call this callback after prepare is completed.
-
preparePostroll
void preparePostroll(@NonNull() InstreamAd.SectionPrepareCallback sectionPrepareCallback)
Initiate prepare for the "postroll" section of video ad.
- Parameters:
sectionPrepareCallback- SDK will call this callback after prepare is completed.
-
resume
void resume()
Resumes ad video from pause
-
setFullscreen
void setFullscreen(boolean fullscreen)
The fullscreen property is intended to inform the InstreamAd component about changing the video playback mode to fullscreen and back. Changing this property affects the sending of the corresponding statistics.
- Parameters:
fullscreen- param is ad in fullscreen mode or not
-
setListener
void setListener(@Nullable() InstreamAd.InstreamAdListener listener)
Set events listener of an advertisement Must be called before InstreamAd.load()
-
setLoadingTimeout
void setLoadingTimeout(int loadingTimeout)
An Ad loading timeout can be set before loading ad. When timeout passes without any callbacks, InstreamAdListener.onNoAd(IAdLoadingError, InstreamAd) 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() InstreamAdPlayer player)
Sets custom implementation of InstreamAdPlayer. Before playing, it must be set player here, or use default player InstreamAd.useDefaultPlayer()
- Parameters:
player- custom player implementation
-
setPostViewPlayer
void setPostViewPlayer(@Nullable() InstreamAdPostViewPlayer postViewPlayer)
Sets implementation of InstreamAdPostViewPlayer. It must be set before playing.
- Parameters:
postViewPlayer- custom player implementation
-
setQrCtaPlayer
void setQrCtaPlayer(@Nullable() QrCtaPlayer qrCtaPlayer)
* Sets implementation of QrCtaPlayer.
- Parameters:
qrCtaPlayer- custom QrCtaPlayer implementation
-
setShoppablePresented
void setShoppablePresented(boolean isPresented)
The fullscreen property is intended to inform the InstreamAd component about showing shoppable ad while playing video or not. Changing this property affects the sending of the corresponding statistics.
- Parameters:
isPresented- param is shoppable ad presented or not
-
setVideoMotionPlayer
void setVideoMotionPlayer(@Nullable() InstreamAdVideoMotionPlayer instreamAdVideoMotionPlayer)
-
setVideoQuality
void setVideoQuality(int videoQuality)
Desired video quality can be set. In vertical pixels. For example, if called
setVideoQuality(360)SDK will try to show video with nearest size, so if ad has ad video with 480x800 and 1920x1080 sizes, 480x800 will be used. Default is 360- Parameters:
videoQuality- desired quality in vertical pixels
-
setVolume
void setVolume(float volume)
Allows you to control the volume of video 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]
-
shoppableAdsItemClick
void shoppableAdsItemClick(@NonNull() String shoppableAdsItemId)
Must be called when the rendered ShoppableAdsItem has been clicked.
- Parameters:
shoppableAdsItemId- is ShopppableAdsItem.
-
shoppableAdsItemShow
void shoppableAdsItemShow(@NonNull() String shoppableAdsItemId)
Should be called when you have rendered the ShoppableAdsItem
- Parameters:
shoppableAdsItemId- is ShoppableAdsItem.
-
skip
void skip()
Explicitly ends playing current section/sequence of ad videos.
-
skipBanner
void skipBanner()
Explicitly ends playing current video banner. Starts next banner then, if exists, or finishes playing video ads section
-
startMidroll
void startMidroll(float point)
Starts the "midroll" section of video ad at
point. An array of available midroll points can be get InstreamAd.getMidPoints().InstreamAdPlayermust be set before calling this function via setPlayer.
-
startPauseroll
void startPauseroll()
Starts the "pauseroll" section of video ad
-
startPostroll
void startPostroll()
Starts the "postroll" section of video ad
-
startPreroll
void startPreroll()
Starts the "preroll" section of video ad
-
stop
void stop()
Stops ad video
-
swapPlayer
void swapPlayer(@Nullable() InstreamAdPlayer player)
Swaps player to another with saving it's state. When app have multiple players, for example, main and small preview players, use this method to swich from one player to another instead of InstreamAd.setPlayer(InstreamAdPlayer)
- Parameters:
player- another player to smooth switch with saving state of video
-
useDefaultPlayer
void useDefaultPlayer()
Sets the default player to play video ads.
-
useDefaultPlayer
void useDefaultPlayer(boolean useExoPlayer)
Sets the default player to play video ads.
- Parameters:
useExoPlayer- determines whether to use ExoPlayer (androidx.
-
-
-
-