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.135.1 or higher of the HTML5 SDK

Enable preloading

To enable preloading, set AdsRenderingSettings.enablePreloading to true. This should 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

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.

Limitations

Preloading is subject to the following limitations:

  • Media preloading is unavailable on the mobile web on iOS devices.
  • Media preloading is unavailable on Android devices with a version prior to 4.0.
  • Preloading is disabled when using manual ad break playback.
  • YouTube-hosted ads, including TrueView formats cannot be preloaded at this time.
  • VPAID will be preloaded, but none of the ad's dependencies, including media played by that ad are loaded until the ad is executed.

FAQ

Is the full creative loaded?
Probably not. This feature is intended for improving the user experience, in particular removing the delay of a few seconds while waiting for an ad to load. It does not intend to support offline ad serving. Depending on internet connection, browser implementation, and creative size, only part of the creative could be buffered, and we will load as much of the media as the browser allows.
Does this apply to the ad's VAST as well as media?
No, the SDK always preloads the ad's VAST, regardless of this preload setting.

Send feedback about...

IMA SDK for HTML5
Need help? Visit our support page.