Class InstreamAd


  • public final class InstreamAd
    extends BaseAd
    • Constructor Detail

      • InstreamAd

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

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

      • getVideoSectionNames

        @NonNull
        public java.util.List<java.lang.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 startPreroll() called, and nothing will happen if 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
      • getLoadingTimeout

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

        public void setLoadingTimeout​(int loadingTimeout)
        An Ad loading timeout can be set before loading ad. When timeout passes without any callbacks, InstreamAd.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
      • getVideoQuality

        public int getVideoQuality()
        Gets desired video quality of loading video. In vertical pixels.
        Returns:
        video
        See Also:
        setVideoQuality(int)
      • setVideoQuality

        public 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
      • getPlayer

        @Nullable
        public 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
        See Also:
        InstreamAdPlayer
      • swapPlayer

        public 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 setPlayer(InstreamAdPlayer)
        Parameters:
        player - another player to smooth switch with saving state of video
      • isFullscreen

        public boolean isFullscreen()
        Returns:
        param is ad in fullscreen mode or not
      • setFullscreen

        public 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
      • isShoppablePresented

        public boolean isShoppablePresented()
        Returns:
        param is shoppable ad presented or not
      • setShoppablePresented

        public 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
      • getVolume

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

        public 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]
      • getMidPoints

        @NonNull
        public float[] getMidPoints()
        Method for getting a list of points at which video 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 video and points set by the application.
        Returns:
        array of midroll points available
      • configureMidpoints

        public 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

        public void configureMidpoints​(float videoDuration,
                                       @Nullable
                                       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 midpoints
        midpoints - an array with desired positions
      • configureMidpointsPercents

        public void configureMidpointsPercents​(float videoDuration,
                                               @Nullable
                                               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 midpoints
        midpointsPercents - an array with desired positions in percents
      • useDefaultPlayer

        public void useDefaultPlayer()
        Sets the default player to play video ads.
      • useDefaultPlayer

        public void useDefaultPlayer​(boolean useExoPlayer)
        Sets the default player to play video ads.
        Parameters:
        useExoPlayer - determines whether to use ExoPlayer or not
      • pause

        public void pause()
        Pauses ad video
      • resume

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

        public void stop()
        Stops ad video
      • skip

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

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

        public void shoppableAdsItemShow​(@NonNull
                                         java.lang.String shoppableAdsItemId)
        Should be called when you have rendered the ShoppableAdsItem
        Parameters:
        shoppableAdsItemId - is ShoppableAdsItem.id
        See Also:
        ShoppableAdsItem
      • shoppableAdsItemClick

        public void shoppableAdsItemClick​(@NonNull
                                          java.lang.String shoppableAdsItemId)
        Must be called when the rendered ShoppableAdsItem has been clicked.
        Parameters:
        shoppableAdsItemId - is ShopppableAdsItem.id
        See Also:
        ShoppableAdsItem
      • handleClick

        public 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
      • destroy

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

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

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

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

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

        public void handleCompanionClick​(@NonNull
                                         InstreamAd.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:
        InstreamAd.InstreamAdCompanionBanner
      • getShoppableView

        @Nullable
        public android.view.View getShoppableView​(android.content.Context context)
        Get the web view with shoppable ad that contains in companion
      • handleAdChoicesClick

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