IMA の読み込み時間を短縮
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
IMA SDK は、ダイナミック広告挿入(DAI)ストリームをリクエストし、視認性を測定し、広告インプレッションを報告するために依存関係を読み込みます。ストリーム リクエストを行う前に IMA を初期化することで、ストリーム再生前に IMA の依存関係を読み込む時間を最大化できます。このページでは、アプリで IMA の読み込み時間を処理する方法について説明します。
ImaSdkFactory.initialize()
に電話
ImaSdkFactory.initialize()
メソッドは、最初のストリーム リクエストの前に SDK リソースのプリロードを開始します。initialize()
を使用するには、IMA バージョン 3.35.1 以降が必要です。
ImaSdkFactory.initialize()
は、アプリの起動時、またはアプリの構造で許される限りアプリのライフサイクルの早い段階で呼び出します。initialize()
呼び出しは次のパラメータを受け取ります。
context
: アプリケーション コンテキストを使用します。このコンテキストは、アプリケーションのライフサイクル中に常に使用できます。
settings
: 値が設定された ImaSdkSettings
オブジェクトを渡します。initialize()
呼び出しで使用される IMA 設定は、createAdsLoader()
呼び出しで使用される設定値と同じである必要があります。IMA SDK は、これらの設定(特に言語設定)をキャッシュキーに使用します。initialize()
メソッド呼び出しで使用される設定にテスト値や偽の値を使用することはおすすめしません。キャッシュミスが発生し、広告の読み込み時間が長くなる可能性があります。
AdsLoader
インスタンスを再利用する
IMA の読み込み時間を短縮するには、同じ AdsLoader
インスタンスを再利用することをおすすめします。AdsLoader
インターフェースは、複数の広告またはストリーム リクエストを処理できます。リクエストごとに新しい AdsLoader
インスタンスを作成しないでください。新しい AdsLoader
インスタンスを作成するには、読み込み時間が必要になり、デバイス リソースが追加で使用されます。
再生前にストリームをリクエストする
ストリーミングの再生を開始する前に AdsLoader
インスタンスにアクセスできる場合は、AdsLoader.requestStream()
メソッドを早めに呼び出すこともできます。この呼び出しを行うと、DAI ストリームの読み込みが開始されます。ユーザーがストリーミング再生を開始する準備ができたら、StreamManager.init()
メソッドを呼び出してストリーミング再生を初期化します。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-21 UTC。
[null,null,["最終更新日 2025-08-21 UTC。"],[],[],null,["# Improve IMA load time\n\nThe IMA SDK loads dependencies to request Dynamic Ad Insertion (DAI) streams,\nmeasure viewability and report ad impressions. By initializing IMA before you\nmake a stream request, you maximize the time to load IMA dependencies before\nstream playback. This page covers how to handling IMA load times in your app.\n\nCall `ImaSdkFactory.initialize()`\n---------------------------------\n\nThe\n[`ImaSdkFactory.initialize()`](/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory#initialize(android.content.Context,com.google.ads.interactivemedia.v3.api.ImaSdkSettings))\nmethod starts to preload SDK resources in advance of the first stream request.\nTo use `initialize()`, you need IMA version 3.35.1 or higher.\n\nCall `ImaSdkFactory.initialize()` on application startup, or as early in the\napplication's lifecycle as your app structure allows. The `initialize()` call\ntakes the following parameters:\n\n- **`context`**: Uses the application context, which is always available during the lifecycle of the application.\n- **`settings`** : Pass the an [`ImaSdkSettings`](/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/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.\n\nReuse the `AdsLoader` instance\n------------------------------\n\nTo improve IMA load time, we recommend you reuse the same\n[`AdsLoader`](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader)\ninstance. The `AdsLoader` interface can handle multiple ad or stream requests.\nAvoid creating a new `AdsLoader` instance for each request. Creating a new\n`AdsLoader` instance requires a load time, and uses additional device resources.\n\nRequest streams in advance of playback\n--------------------------------------\n\nIf you have access to the `AdsLoader` instance prior to starting stream\nplayback, you can also call the\n[`AdsLoader.requestStream()`](/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader#requestStream(com.google.ads.interactivemedia.v3.api.StreamRequest))\nmethod early. Making this call starts loading the DAI stream. When the user\nis ready to start stream playback, call the\n[`StreamManager.init()`](/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager#init())\nmethod to initialize stream playback."]]