Улучшить время загрузки IMA,Улучшить время загрузки IMA

The IMA SDK loads dependencies to request ads, measure viewability and report ad impressions. By initializing IMA before you make an ad request, you maximize the time to load IMA dependencies before ad playback. This page covers how to handling IMA load times in your app.

Вызовите метод ImaSdkFactory.initialize()

Метод ImaSdkFactory.initialize() начинает предварительную загрузку ресурсов SDK до первого запроса рекламы. Для использования initialize() необходима версия IMA 3.35.1 или выше.

Вызывайте метод ImaSdkFactory.initialize() при запуске приложения или на самом раннем этапе жизненного цикла приложения, насколько это позволяет структура вашего приложения. Вызов initialize() принимает следующие параметры:

  • context : Использует контекст приложения, который всегда доступен на протяжении всего жизненного цикла приложения.
  • settings : Pass the an ImaSdkSettings object with its values set. The IMA settings used in the initialize() call must be the same as the settings values used in the createAdsLoader() call. The IMA SDK utilizes these settings, particularly the language setting, for cache key. We don't recommend using test or fake values for the settings used in the initialize() method call, as cache misses might occur and increase ad load time.

Повторно используйте экземпляр AdsLoader .

To improve IMA load time, we recommend you reuse the same AdsLoader instance. The AdsLoader interface can handle multiple ad or stream requests. Avoid creating a new AdsLoader instance for each request. Creating a new AdsLoader instance requires a load time, and uses additional device resources.

Запросить показ рекламы до начала воспроизведения

If you have access to the AdsLoader instance prior to starting ad playback, you can also call the AdsLoader.requestAds() method early. Making this call starts loading pre-roll ads. When the user is ready to start content playback, call the AdsManager.init() method and wait for the LOADED event to play ads.