檢舉連續播放
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 的 IMA SDK 可讓您設定
廣告請求。
setContinuousPlayback()
方法會通知 SDK 播放器是否打算連續播放內容影片
類似電視節目設為
true
時,系統會從
請求是由廣告伺服器指定適合連續播放。非
呼叫這個方法
則將設定維持在不明狀態
以下範例說明如何在廣告請求中設定連續播放。
AdsRequest request = mSdkFactory.createAdsRequest();
request.setAdTagUrl(adTagUrl);
request.setContinuousPlayback(true);
adsLoader.requestAds(request);
敬上
對於使用
Exoplayer-IMA 擴充功能
2.13 以上版本,或
BasicExample
以下範例顯示實作擴充功能的方法,如要設定連續播放功能,請參閱以下範例。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
playerView = findViewById(R.id.player_view);
ImaAdsLoader.Builder builder = new ImaAdsLoader.Builder(this).setContinuousPlayback(true);
adsLoader = builder.build();
}
連續播放與廣告自動播放的差異
Android 專用的 IMA SDK 還可讓您設定播放器是否會開始播放
自動或等待使用者動作開始播放。方法是使用
setAdWillAutoPlay()
方法。設為
true
時,系統會傳回廣告指定的廣告
適用於自動播放環境
此表格詳細列出根據影片內容,要求連續播放和自動播放廣告的時機
與廣告配對
影片內容 |
setContinuousPlayback() 參數 |
setAdWillAutoPlay() 的參數 |
在使用者進行互動時播放的單一內容影片 |
false |
false |
自動播放的單一內容影片 |
false |
true |
在使用者進行互動後,播放第一部影片但自動播放
追蹤的影片 |
true |
false |
自動播放第一部影片並自動播放下列影片的影片播放清單 |
true |
true |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-01 (世界標準時間)。
[null,null,["上次更新時間:2025-08-01 (世界標準時間)。"],[[["\u003cp\u003eThe IMA SDK for Android allows you to specify whether your content videos will play continuously, impacting the types of ads returned.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003esetContinuousPlayback(true)\u003c/code\u003e when your content videos will autoplay or play in a sequence similar to a TV broadcast.\u003c/p\u003e\n"],["\u003cp\u003eContinuous play is independent of ad auto-play, which is controlled using the \u003ccode\u003esetAdWillAutoPlay()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe table provides guidance on when to use \u003ccode\u003esetContinuousPlayback()\u003c/code\u003e and \u003ccode\u003esetAdWillAutoPlay()\u003c/code\u003e based on your video content's autoplay behavior.\u003c/p\u003e\n"]]],[],null,["# Report continuous play\n\nThe IMA SDK for Android allows for setting the continuous play context for an ads request. The `\n`[setContinuousPlayback()](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest#setContinuousPlayback(boolean)) method notifies the SDK whether the player intends to continuously play the content videos one after another, similar to a TV broadcast. When set to `true`, the ads returned from the request are those designated by the ads server as suitable for continuous play. Not calling this method leaves the setting as unknown. **Note:** Changing this setting has no impact on ad playback.\nThe following sample demonstrates how to set continuous play in an ads request. \n\n```text\nAdsRequest request = mSdkFactory.createAdsRequest();\nrequest.setAdTagUrl(adTagUrl);\nrequest.setContinuousPlayback(true);\nadsLoader.requestAds(request);\n```\nFor those using the [Exoplayer-IMA extension](//github.com/google/ExoPlayer/tree/release-v2/extensions/ima), version 2.13 or later, or the [BasicExample](//github.com/googleads/googleads-ima-android/tree/master/BasicExample) which implements the extension, the following sample shows how to set continuous play. \n\n```transact-sql\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_my);\n\n playerView = findViewById(R.id.player_view);\n\n ImaAdsLoader.Builder builder = new ImaAdsLoader.Builder(this).setContinuousPlayback(true);\n adsLoader = builder.build();\n}\n```\n\nHow continuous play differs from ad auto-play\n---------------------------------------------\n\nThe IMA SDK for Android also allows for setting whether the player will start playing automatically or wait for user action to begin playing. This is done using the `\n`[setAdWillAutoPlay()](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest#setAdWillAutoPlay(boolean)) method. When set to `true`, the ads returned are those designated by the ads server as suitable for an auto-play environment.\n\n\nThis table details when to request ads for continuous play and auto-play, based on the video content\nthe ads are paired with.\n\n| Video Content | Parameter for setContinuousPlayback() | Parameter for setAdWillAutoPlay() |\n|------------------------------------------------------------------------------------------------------|---------------------------------------|-----------------------------------|\n| A single content video that plays upon user interaction | `false` | `false` |\n| A single content video that autoplays | `false` | `true` |\n| A video playlist that plays the first video upon user interaction but autoplays the following videos | `true` | `false` |\n| A video playlist that autoplays the first video and autoplays the following videos | `true` | `true` |"]]