Opt-in video integration

Last updated on November 5, 2018

Opt-in videoA type of linear video ad or ad unit associated with mobile apps. A user opts into watching a full-screen, non-skippable video ad in exchange for a non-liquid, in-app reward after viewing the entire ad. Examples of rewards are: access to premium content or features, an extra life, continued play, a coupon, a discount code, or something else without monetary value. Opt-in video is also known as rewarded video and is not the same as incentivized video. in the OpenX Mobile Android SDK is in Beta release only. For more information, contact OpenX.

If you are participating in the Beta, you can integrate opt-in video 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 an opt-in video (rewarded video) ad in your app, please do the following:

  1. Either create a linear video ad unit with the Is Rewarded check box selected 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

  1. To create an opt-in video ad, create a new object of the type AdView as shown below. Please note that a VAST tag always looks like this: "DOMAIN/v/1.0/av?auid=AUID" (where DOMAIN is your OpenX delivery domainThe domain on which ads will be served for your OpenX inventory. OpenX Partner Services provide this to you so you can set up your implementation. For example: PUBLISHER-d.openx.net., and AUID is the OpenX ad unit ID).
  2. public class MainActivity extends Activity {
     
    	private AdView mAdViewVideo;
     
    	@Override	
    	protected void onCreate(Bundle savedInstanceState) {
    		...
     
    		loadAd();
    	}
      
    	private void loadAd() {
     
    		try {
    			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. For a better user experience, preload the video as shown below. Note that the SDK will not preload video ads larger than 25 MiB.

      properties.preloadVideo = true;
    3. 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. 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. Set the ad unit as an opt-in video.
    mAdViewVideo.setRewardedFlag(true);
  8. Load the ad.
    mAdViewVideo.load();
  9. 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();
  10. 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.