檢舉連續播放
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
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 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-01 (世界標準時間)。
[null,null,["上次更新時間: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` |"]]