Video interstitial integration

Last updated on June 6, 2019

You can integrate video interstitialA full-screen ad displayed in content transitions. For example, a video ad that loads between levels of a mobile game. ads in the OpenX Mobile Android SDK. The supported video ad formats include .mp4, .3gpp, .webm, and .mkv.

Overview

Prerequisites

Integration

Data enrichment

Prerequisites

Before integrating a video interstitial ad in your app, please do the following:

  1. Either create a linear video ad unit or make sure you know which existing ad unitThe smallest inventory component that represents the space on a site where ads display. to use.
  2. Update your Android manifest, as described in Android SDK integration.

Integration

Some integration steps vary as indicated, depending on which OpenX Mobile SDK version you are using.

  1. To create a video interstitial ad, create a new object of the type AdView as shown below.
  2. public class MainActivity extends Activity {
     
    	private AdView mAdViewVideo;
     
    	@Override	
    	protected void onCreate(Bundle savedInstanceState) {
    		...
     
    		loadAd();
    	}
      
    	private void loadAd() {
     
    		try {
    			// For OpenX mobile SDK version 4.9 or later:
    			mInterstitialView = new InterstitialView(this,”mobile-d.openx.net”, “123456789”, InterstitialView.AdType.VAST);		
    			// For OpenX mobile SDK versions earlier than 4.90:		
    			mAdViewVideo = new AdView(this, "http://mobile-d.openx.net/v/1.0/av?auid=539733507");
    		}
    		catch (AdException e) {
    			Log.e(TAG, "Something went wrong! Error: " + e.getMessage());
    			return;
    		}
    					
    		...
    	}
    }
  3. Set AutoDisplayOnLoad to false to avoid displaying the video right after it finishes loading.

    mAdViewVideo.setAutoDisplayOnLoad(false);

  4. Set the opacity of the video frame. The recommended value is 1.0f (opaque).
    mAdViewVideo.interstitialDisplayProperties.setPubBackGroundOpacity(1.0f);
  5. Use InterstitialVideoProperties to set video properties.
    1. Create an InterstitialVideoProperties object:

      InterstitialVideoProperties properties = new InterstitialVideoProperties();

    2. In OpenX Mobile SDK versions earlier than 4.9 only: For a better user experience, preload the video as shown below. By default, preLoadVideo is set to true, but if you still prefer to stream the video, set preLoadVideo to false. Note that the SDK will not preload video ads larger than 25 MiB.

      properties.preloadVideo = true;
    3. In OpenX Mobile SDK versions earlier than 4.9 only: Use autoPreloadConfigs to specify the network scenario where the video is to be preloaded. The default is Wi-Fi only.
      properties.autoPreloadConfigs = VideoProperties.AutoVideoPreloadConfigs.WifiOnlyAutoPreload;
    4. Use closeButtonDelayinSecs to display the Close button on the video ad at the desired interval.
      • Videos that span 2 seconds or less cannot be closed early.
      • Videos longer than 2 seconds will display a Close button at 2 seconds by default (recommended).

      If you prefer customizing the video duration, set the limits as described below. All values are in seconds.

      Note: The upper limit is the end of video or 30 seconds, whichever is less.

       

      Video ad duration

      Custom value

      Result

      <= 2

      Ignored End of video

      > 2

      Nil, value < 22

      > 2

      2 <= value <= upper limit Value

      > 2

      Value > upper limit Upper limit

       

    5. After you have set the video properties, attach them to AdView.

      mAdViewVideo.setInterstitialVideoProperties(properties);
  6. Create and attach AdEventsListener to AdView to get the life cycle events of the ad. For details on available events, see Callbacks.

    mAdViewVideo.addAdEventListener(new AdEventsListener() {
         
    	@Override
    	public void adDidLoad(AdView adView, AdDetails adDetails) {
     
    	}
     
    	...
    };
  7. Load the ad.
    mAdViewVideo.load();
  8. At any point after the ad is loaded, which is indicated by the adDidLoad() event being called inside your AdEventsListener, you can display the ad.
    mAdViewVideo.showVideoAsInterstitial();
  9. Be sure to destroy the AdView object during the cleanup.
    @Override
    protected void onDestroy() {
    	...
    
    	if (null != adViewVideo) {
    		mAdViewVideo.destroy();
    		mAdViewVideo = null;
    	}
    }

Data enrichment

For information about enriching data in the ad requestCommunication from a web browser or app to an ad server to display an ad., please see Parameters.

Fill out my online form.