Preloading media

The IMA SDK supports preloading video ad assets. You can enable this feature in your 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.

Enable preloading

To enable preloading, set AdsRenderingSettings.enablePreloading to true. This must be done as a result of the ADS_MANAGER_LOADED event:

function onAdsManagerLoaded(adsManagerLoadedEvent) {
  var adsRenderingSettings = new google.ima.AdsRenderingSettings();
  adsRenderingSettings.enablePreloading = true;
  ...
  var adsManager = adsManagerLoadedEvent.getAdsManager(
      videoContent, adsRenderingSettings);
}

Timing

The following 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.

Limitations

Preloading is subject to the following limitations:

  • Media preloading is not available on the mobile web on iOS devices or when using the HTML5 IMA SDK on connected smart TVs.
  • VPAID is preloaded, but none of the ad's dependencies—including media played by that ad—are loaded until the ad is executed.
  • Autoplay must be enabled for preloading to work. Ensure that settings.isAutoPlayAdBreaks() is set to true, which is the default value.

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 loads 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.