返回略過的廣告時段
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
影片發布商可能會希望觀眾
尋找略過片中廣告使用者跳轉而略過廣告插播時
可以直接回到廣告插播的開始時間
廣告播放完畢後,就會前往尋找地點這個
功能稱為「回溯」
請參考下圖範例。觀眾正在觀看影片
並決定從 5 分鐘的標記跳轉至 15 分鐘的位置。
但在 10 分鐘標記處加入廣告插播時間點
然後才觀看內容:

如要顯示這個廣告插播時間點,請按照下列步驟操作:
- 檢查使用者是否跳轉到未觀看的廣告時段。
如果有,請將觀眾帶回廣告插播時間點
- 廣告插播時間點後,請回到原本的時間點。
圖表形式如下所示:

以下說明如何在 IMA DAI SDK 中實作此工作流程,如
AdvancedExample。
避免跳轉,讓觀眾在不知情的情況下離開廣告插播時間
檢查使用者是否已略過未觀看的廣告插播,如果是的話,請將他們帶回廣告插播。針對 iOS Advanced 範例,請使用使用者與使用者介面的互動方式
偵測他們何時開始跳轉保留搜尋開始時間,以便檢查是否已在搜尋中略過未播放的廣告時段。當使用者
釋出影片控制介面,並比較其目前時間與
最近的廣告插播時間點如果廣告插播時間點在跳轉時間點之後
時間 (也就是使用者跳過這關) 且未播放過
以便將觀眾導回廣告時段的開頭。此外,設定回溯旗標
稍後在廣告插播完整處理常式中檢查:
- (IBAction)videoControlsTouchStarted:(id)sender {
self.seekStartTime = self.contentPlayer.currentTime;
}
- (IBAction)videoControlsTouchEnded:(id)sender {
self.seekEndTime = CMTimeMake(self.progressBar.value, 1);
IMACuepoint *lastCuepoint =
[self.streamManager previousCuepointForStreamTime:CMTimeGetSeconds(self.seekEndTime)];
if (!lastCuepoint.played && (lastCuepoint.startTime > CMTimeGetSeconds(self.seekStartTime))) {
self.snapbackMode = YES
// Add 1 to the seek time to get the keyframe at the start of the ad to be your landing place.
[self.contentPlayer seekToTime:CMTimeMakeWithSeconds(lastCuepoint.startTime + 1, NSEC_PER_SEC)];
}
}
讓使用者回到原本的搜尋頁面
在廣告插播的處理常式中,檢查
因回溯而播放中斷。如果是的話,請傳回使用者
他們原本想去的地方 (只要這邊只是
不是剛播放的廣告插播中間):
- (void)streamManager:(IMAStreamManager *)streamManager didReceiveAdEvent:(IMAAdEvent *)event {
switch (event.type) {
case kIMAAdEvent_AD_BREAK_ENDED: {
if (self.snapbackMode) {
self.snapbackMode = NO;
if (CMTimeCompare(self.seekEndTime, self.contentPlayer.currentTime)) {
[self.contentPlayer seekToTime:self.seekEndTime];
}
}
break;
}
}
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-21 (世界標準時間)。
[null,null,["上次更新時間:2025-08-21 (世界標準時間)。"],[[["\u003cp\u003eSnapback prevents viewers from skipping mid-roll ads by returning them to the start of the ad break if they seek past it.\u003c/p\u003e\n"],["\u003cp\u003eWhen a viewer seeks past an unwatched ad, the feature takes them back to the ad and then returns them to their intended location after the ad completes.\u003c/p\u003e\n"],["\u003cp\u003eImplementing snapback involves checking for seeks that bypass unwatched ads and using ad break event handlers to redirect the viewer accordingly.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code snippets demonstrate how to detect ad-skipping seeks and trigger the snapback functionality within the IMA DAI SDK.\u003c/p\u003e\n"]]],[],null,["# Return to a skipped ad break\n\nAs a video publisher, you may want to prevent your viewers from\nseeking past your mid-roll ads. When a user seeks past an ad break,\nyou can take them back to the start of that ad break, and then return\nthem to their seek location after that ad break has completed. This\nfeature is called \"snapback.\"\n\nAs an example, see the diagram below. Your viewer is watching a video,\nand decides to seek from the 5-minute mark to the 15-minute mark.\nThere is, however, an ad break at the 10-minute mark that you want\nthem to watch before they can watch the content after it:\n\nIn order to show this ad break, take the following steps:\n\n1. Check if the user ran a seek that jumped past an unwatched ad break, and if so, take them back to the ad break.\n2. After the ad break completes, return them to their original seek.\n\nIn diagram form, that looks like this:\n\nHere's how to implement this workflow in the IMA DAI SDK, as done in the\n[AdvancedExample](//github.com/googleads/googleads-ima-ios-dai).\n\nPrevent a seek from leaving an ad break unwatched\n-------------------------------------------------\n\nCheck if the user has run a seek that went past an unwatched ad break,\nand if so, take them back to the ad break.\nFor the iOS Advanced example, use the user's interaction with your UI\nto detect when they have run a seek. Preserve the seek start time to check\nif they've passed an unplayed ad break in their seek. When the user\nreleases the video controls, compare their current time to the time of\nthe most recent ad break. If the ad break falls after the seek start\ntime (meaning the user has jumped past it) and it hasn't yet been played,\nseek them back to the start of the ad break. Also, set a snapback flag\nto check later in your ad break complete handler: \n\n - (IBAction)videoControlsTouchStarted:(id)sender {\n self.seekStartTime = self.contentPlayer.currentTime;\n }\n\n - (IBAction)videoControlsTouchEnded:(id)sender {\n self.seekEndTime = CMTimeMake(self.progressBar.value, 1);\n IMACuepoint *lastCuepoint =\n [self.streamManager previousCuepointForStreamTime:CMTimeGetSeconds(self.seekEndTime)];\n if (!lastCuepoint.played && (lastCuepoint.startTime \u003e CMTimeGetSeconds(self.seekStartTime))) {\n self.snapbackMode = YES\n // Add 1 to the seek time to get the keyframe at the start of the ad to be your landing place.\n [self.contentPlayer seekToTime:CMTimeMakeWithSeconds(lastCuepoint.startTime + 1, NSEC_PER_SEC)];\n }\n }\n\nPut the user back to their original seek\n----------------------------------------\n\nIn your ad-break-ended handler, check to see if the previous\nbreak was played as the result of snapback. If so, return the user\nto the place they were trying to seek to initially (as long as it\nwasn't the middle of the ad break that just played): \n\n - (void)streamManager:(IMAStreamManager *)streamManager didReceiveAdEvent:(IMAAdEvent *)event {\n switch (event.type) {\n case kIMAAdEvent_AD_BREAK_ENDED: {\n if (self.snapbackMode) {\n self.snapbackMode = NO;\n if (CMTimeCompare(self.seekEndTime, self.contentPlayer.currentTime)) {\n [self.contentPlayer seekToTime:self.seekEndTime];\n }\n }\n break;\n }\n }\n }"]]