报告连续播放
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助适用于 iOS 的 IMA SDK,您可以针对
广告请求。
continuousPlayback
属性会通知 SDK 播放器是否会在一个内容视频播放完后继续播放其他内容视频(类似于电视广播)。设置为
true
时,从请求返回的广告是广告服务器指定为适合连续播放的广告。非
指定
此媒体资源
将设置保留为未知状态。
以下示例演示了如何在广告请求中设置连续播放。
Objective-C
IMAAdsRequest *request = [[IMAAdsRequest alloc]
initWithAdTagUrl:adTagUrl
adDisplayContainer:[self createAdDisplayContainer]
avPlayerVideoDisplay:[[IMAAVPlayerVideoDisplay alloc] initWithAVPlayer:self.contentPlayer]
pictureInPictureProxy:self.pictureInPictureProxy
userContext:nil];
request.continuousPlayback = true;
[self.adsLoader requestAdsWithRequest:request];
Swift
let request = IMAAdsRequest(
adTagUrl: adTagUrl,
adDisplayContainer: createAdDisplayContainer(),
avPlayerVideoDisplay: IMAAVPlayerVideoDisplay(avPlayer: contentPlayer),
pictureInPictureProxy: pictureInPictureProxy,
userContext: nil)
request.continuousPlayback = true;
adsLoader!.requestAds(with: request)
连续播放与广告自动播放的区别
适用于 iOS 的 IMA SDK 还允许设置播放器是自动开始播放还是等待用户操作后开始播放。您可以使用
adWillAutoPlay
属性。如果设置为
true
,则返回的广告是广告服务器指定为适合自动播放环境的广告。
下表详细介绍了何时请求连续播放和自动播放广告,具体取决于广告与哪些视频内容搭配使用。
视频内容 |
ContinuousPlayback 的值 |
adWillAutoPlay 的值 |
在用户互动时播放的单个内容视频 |
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 iOS allows you to specify whether your content videos will play continuously, influencing the types of ads returned by the ad server.\u003c/p\u003e\n"],["\u003cp\u003eSetting \u003ccode\u003econtinuousPlayback\u003c/code\u003e to \u003ccode\u003etrue\u003c/code\u003e signals that videos will play one after another, like a TV broadcast, and is suitable for video playlists with autoplay.\u003c/p\u003e\n"],["\u003cp\u003eWhile \u003ccode\u003econtinuousPlayback\u003c/code\u003e impacts ad selection, it does not affect ad playback; \u003ccode\u003eadWillAutoPlay\u003c/code\u003e controls whether ads start playing automatically.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003eadWillAutoPlay\u003c/code\u003e set to \u003ccode\u003etrue\u003c/code\u003e when your single content video or video playlist starts playing automatically without user interaction.\u003c/p\u003e\n"],["\u003cp\u003eConsult the provided table to determine the appropriate settings for \u003ccode\u003econtinuousPlayback\u003c/code\u003e and \u003ccode\u003eadWillAutoPlay\u003c/code\u003e based on your specific video content behavior.\u003c/p\u003e\n"]]],[],null,["# Report continuous play\n\nThe IMA SDK for iOS allows for setting the continuous play context for an ads request. The `\n`[continuousPlayback](/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMAAdsRequest#continuousplayback) property 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 specifying a value for this property 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### Objective-C\n\n```objective-c\nIMAAdsRequest *request = [[IMAAdsRequest alloc]\n initWithAdTagUrl:adTagUrl\n adDisplayContainer:[self createAdDisplayContainer]\n avPlayerVideoDisplay:[[IMAAVPlayerVideoDisplay alloc] initWithAVPlayer:self.contentPlayer]\n pictureInPictureProxy:self.pictureInPictureProxy\n userContext:nil];\n request.continuousPlayback = true;\n [self.adsLoader requestAdsWithRequest:request];\n```\n\n### Swift\n\n```swift\nlet request = IMAAdsRequest(\n adTagUrl: adTagUrl,\n adDisplayContainer: createAdDisplayContainer(),\n avPlayerVideoDisplay: IMAAVPlayerVideoDisplay(avPlayer: contentPlayer),\n pictureInPictureProxy: pictureInPictureProxy,\n userContext: nil)\nrequest.continuousPlayback = true;\nadsLoader!.requestAds(with: request)\n```\n\nHow continuous play differs from ad auto-play\n---------------------------------------------\n\nThe IMA SDK for iOS 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`[adWillAutoPlay](/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMAAdsRequest#adwillautoplay) property. 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 | Value for continuousPlayback | Value for adWillAutoPlay |\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` |"]]