报告连续播放
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您可以使用 IMA SDK for Android 为
广告请求。通过
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();
}
连续播放与广告自动播放的区别
通过 IMA SDK for Android,您还可以设置播放器是否开始播放
或等待用户操作开始播放。您可以使用
setAdWillAutoPlay()
方法。如果设置为
true
,则返回的广告是由广告指定的
以适合自动播放环境。
下表详细说明了何时根据视频内容请求连续播放和自动播放广告
广告的配对对象。
视频内容 |
setContinuousPlayback() 的参数 |
setAdWillAutoPlay() 的参数 |
用户互动时播放的单个内容视频 |
false |
false |
自动播放的单个内容视频 |
false |
true |
用户互动时播放第一个视频但会自动播放
关注视频 |
true |
false |
自动播放第一个视频并自动播放后续视频的视频播放列表 |
true |
true |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-01。
[null,null,["最后更新时间 (UTC):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` |"]]