Preloading Media

The IMA SDK supports preloading video ad assets in advance. Publishers can enable this feature in their SDK integration to provide a more seamless transition between ads and content. This guide goes over the technical details of implementing media preload with the IMA SDK.

Prerequisite

  • Version 3.17.0 or higher of the IMA Android SDK

Enable preloading

To enable preloading, use AdsRenderingSettings.setEnablePreloading() to set preloading to true. This should be done within the onAdsManagerLoaded() callback:

@Override
public void onAdsManagerLoaded(AdsManagerLoadedEvent adsManagerLoadedEvent) {
  ...
  AdsRenderingSettings adsRenderingSettings =
      ImaSdkFactory.getInstance().createAdsRenderingSettings();
  adsRenderingSettings.setEnablePreloading(true);
  mAdsManager.init(adsRenderingSettings);
}

Timing

This table summarizes the changes in ad-load timing when preloading is enabled:

Event With Preload Without Preload
Ad VAST requested AdsLoader.requestAds() AdsLoader.requestAds()
Pre-roll loaded (single ad) AdsManager.init() AdsManager.start()
Pre-roll loaded (VMAP/Ad rules) AdsManager.init() AdsManager.init()
Mid-roll or post-roll loaded For the 1st ad in an ad break, 4 seconds before ad start time. For consecutive ads, when the previous ad starts playing. At ad start time.

FAQ

Does media preloading load the full creative?
No, the creative is usually not fully loaded when ad playback begins. Preloading is intended for improving the user experience by minimizing the time it takes for the ad to load. It is not intended to support offline ad serving. The IMA SDK will load as much of the media as the browser allows, limited by the user's internet connection and the size of the creative.
Does media preloading need to be enabled for the ad's VAST as well as media?
No, the SDK always preloads the ad's VAST, regardless of this preload setting.