Skip to end of metadata
Go to start of metadata

JavaScript is disabled on your browser.
com.appnexus.opensdk.instreamvideo

Class VideoAd

  • java.lang.Object
    • com.appnexus.opensdk.instreamvideo.VideoAd


  • public class VideoAd
    extends java.lang.Object
    • Constructor Detail

      • VideoAd

        public VideoAd(android.content.Context context,
                       java.lang.String placementID)
      • VideoAd

        public VideoAd(android.content.Context context,
                       java.lang.String inventoryCode,
                       int memberID)
    • Method Detail

      • getOpensNativeBrowser

        public boolean getOpensNativeBrowser()
        Deprecated. Use getClickThroughAction instead Refer ANClickThroughAction
        Retrieve the setting that determines whether or not the device's native browser is used instead of the in-app browser when the user clicks an ad.
        Returns:
        true if the device's native browser will be used; false otherwise.
      • setOpensNativeBrowser

        public void setOpensNativeBrowser(boolean opensNativeBrowser)
        Deprecated. Use setClickThroughAction instead Refer ANClickThroughAction
        Set this to true to disable the in-app browser. This will cause URLs to open in a native browser such as Chrome so that when the user clicks on an ad, your app will be paused and the native browser will open. Set this to false to enable the in-app browser instead (a lightweight browser that runs within your app). The default value is false.
        Parameters:
        opensNativeBrowser -
      • setPlacementID

        public void setPlacementID(java.lang.String placementID)
        Sets the placement id of the VideoAd. The placement ID identifies the location in your application where ads will be shown. You must have a valid, active placement ID to monetize your application.
        Parameters:
        placementID - The placement ID to use.
      • getPlacementID

        public java.lang.String getPlacementID()
        Retrieve the placement id for ad request.
        Returns:
        The Placement ID
      • setInventoryCodeAndMemberID

        public void setInventoryCodeAndMemberID(int memberID,
                                                java.lang.String inventoryCode)
        Sets the inventory code and member id of this Video ad request. The inventory code provides a more human readable way to identify the location in your application where ads will be shown. Member id is required to for using this feature. If both inventory code and placement id are presented, inventory code will be used instead of placement id on the ad request.
        Parameters:
        memberID - The member id that this Video ad belongs to.
        inventoryCode - The inventory code of this Video ad.
      • getMemberID

        public int getMemberID()
        Retrieve the member ID.
        Returns:
        the member id that this AdView belongs to.
      • getInventoryCode

        public java.lang.String getInventoryCode()
        Retrieve the inventory code.
        Returns:
        the current inventory code.
      • setGender

        public void setGender(AdView.GENDER gender)
        Set user's gender for targeting
        Parameters:
        gender - User's gender
      • getGender

        public AdView.GENDER getGender()
        Get the user's gender
        Returns:
        User's gender
      • setAge

        public void setAge(java.lang.String age)
        Set the age or age range of the user
        Parameters:
        age - User's age or age range
      • getAge

        public java.lang.String getAge()
        Get the age or age range for the ad request
        Returns:
        age
      • setExternalUid

        public void setExternalUid(java.lang.String externalUid)
        Set the current user's externalUID
        Parameters:
        externalUid - .
      • getExternalUid

        public java.lang.String getExternalUid()
        Retrieve the externalUID that was previously set.
        Returns:
        externalUID.
      • addCustomKeywords

        public void addCustomKeywords(java.lang.String key,
                                      java.lang.String value)
        Add a custom keyword to the request URL for the ad. This is used to set custom targeting parameters within the AppNexus platform. You will be given the keys and values to use by your AppNexus account representative or your ad network.
        Parameters:
        key - The key to add; this cannot be null or empty.
        value - The value to add; this cannot be null or empty.
      • removeCustomKeyword

        public void removeCustomKeyword(java.lang.String key)
        Remove a custom keyword from the request URL for the ad. Use this to remove a keyword previously set using addCustomKeywords.
        Parameters:
        key - The key to remove; this cannot be null or empty.
      • clearCustomKeywords

        public void clearCustomKeywords()
        Clear all custom keywords from the request URL.
      • getAdMinDuration

        public int getAdMinDuration()
        use this to get the min duration set for the video tag
        Returns:
        min duration set in seconds
      • setAdMinDuration

        public void setAdMinDuration(int minDuration)
        use this to set the min duration for the video tag
        Parameters:
        minDuration - the min duration value in seconds
      • getAdMaxDuration

        public int getAdMaxDuration()
        use this to get the max duration set for the video tag
        Returns:
        max duration value in seconds
      • setAdMaxDuration

        public void setAdMaxDuration(int maxDuration)
        use this to set the max duration for the video tag
        Parameters:
        maxDuration - the max duration value in seconds
      • setAdLoadListener

        public void setAdLoadListener(VideoAdLoadListener adLoadListener)
        Register a listener for ad success/fail to load notification events
        Parameters:
        adLoadListener - The Listener to register
      • getAdLoadListener

        public VideoAdLoadListener getAdLoadListener()
        Get the listener that listens the state of the request
        Returns:
        The registered ad-load listener
      • setVideoPlaybackListener

        public void setVideoPlaybackListener(VideoAdPlaybackListener videoPlaybackListener)
        Register a videoPlaybackListener for Video Events callback like Quartiles/Play/Pause/Completed.
        Parameters:
        videoPlaybackListener - The VideoAdPlaybackListener listener to register
      • getVideoPlaybackListener

        public VideoAdPlaybackListener getVideoPlaybackListener()
        Get the listener that listens the state of the video
        Returns:
        The registered video event listener
      • getMediaType

        public com.appnexus.opensdk.MediaType getMediaType()
        Media type can be Banner, Interstitial, Native or Video
        Returns:
        the media type of this ad
      • isReadyToStart

        public boolean isReadyToStart()
        Checks whether an ad is ready to load a new one
        Returns:
        true if settings are ready to load a new ad
      • loadAd

        public boolean loadAd()
        Call this to request a VideoAd for parameters described by this object.
        Returns:
        true if ad request is scheduled successfully
      • removeAd

        public void removeAd()
        Call this to remove the video ad view from the container.
      • isReady

        public boolean isReady()
        Checks the queue to see if there is a valid video ad available.
        Returns:
        true if there is a valid ad available in the queue, false otherwise.
      • setClickThroughAction

        public void setClickThroughAction(ANClickThroughAction clickThroughAction)
        Determines what action to take when the user clicks on an ad. If set to ANClickThroughAction.OPEN_DEVICE_BROWSER/ANClickThroughAction.OPEN_SDK_BROWSER then, VideoAdPlaybackListener.onAdClicked(VideoAd videoAd) will be triggered and corresponding browser will load the click url. If set to ANClickThroughAction.RETURN_URL then, VideoAdPlaybackListener.onAdClicked(VideoAd videoAd, String clickUrl) will be triggered with clickUrl as its argument. It is ASSUMED that the App will handle it appropriately.
        Parameters:
        clickThroughAction - ANClickThroughAction.OPEN_SDK_BROWSER which is default or ANClickThroughAction.OPEN_DEVICE_BROWSER or ANClickThroughAction.RETURN_URL
      • activityOnDestroy

        public void activityOnDestroy()
      • activityOnPause

        public void activityOnPause()
      • activityOnResume

        public void activityOnResume()
      • setLoadsInBackground

        public void setLoadsInBackground(boolean doesLoadingInBackground)
        Sets whether or not to load landing pages in the background before displaying them. This feature is on by default, but only works with the in-app browser (which is also enabled by default). Disabling this feature may cause redirects, such as to the app store, to first open a blank web page.
        Parameters:
        doesLoadingInBackground - Whether or not to load landing pages in background.
      • getLoadsInBackground

        public boolean getLoadsInBackground()
        Gets whether or not this AdView will load landing pages in the background before displaying them. This feature is on by default, but only works with the in-app browser (which is also enabled by default). Disabling this feature may cause redirects, such as to the app store, to first open a blank web page.
        Returns:
        Whether or not redirects and landing pages are loaded/processed in the background before being displayed.
      • getShowLoadingIndicator

        public boolean getShowLoadingIndicator()
        Get whether or not the Video Ad should show the loading indicator after being pressed, but before able to launch the browser.

        Default is true

        Returns:
        true if the loading indicator will be displayed, else false
      • setShowLoadingIndicator

        public void setShowLoadingIndicator(boolean show)
        Set whether or not the Video Ad should show the loading indicator after being pressed, but before able to launch the browser.

        Default is true

        Parameters:
        show - True if you desire the loading indicator to be displayed, else set to false
      • playAd

        public void playAd(android.widget.FrameLayout layout)
        Call this by passing a Container(FrameLayout) when you want the VideoAd to Play.
        Parameters:
        layout - The layout in which the Video Ad will be attached to. Pass a FrameLayout.
      • playAd

        public void playAd(android.widget.RelativeLayout layout)
        Call this by passing a Container(RelativeLayout) when you want the VideoAd to Play.
        Parameters:
        layout - The layout in which the Video Ad will be attached to. Pass a RelativeLayout.
      • getCreativeURL

        public java.lang.String getCreativeURL()
      • getVastURL

        public java.lang.String getVastURL()
      • getVideoAdDuration

        public int getVideoAdDuration()
      • getCreativeId

        public java.lang.String getCreativeId()
        Retrieve the Creative Id of the creative .
        Returns:
        the creativeId
      • getVastXML

        public java.lang.String getVastXML()
      • getAdPlayElapsedTime

        public void getAdPlayElapsedTime(ResultCallback resultCallback)
        Asynchronously calls the VideoAd and gets the current ad play elapsed time in milliseconds. \resultCallback\ will be invoked with the result. Works only on KITKAT and above.
        Parameters:
        resultCallback - A callback to be invoked when the execution is complete completes with the result of the execution (if any). May be null or empty string.

  • No labels