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

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

以下說明如何使用 IMA DAI SDK 導入 Snapack,如
進階範例。
避免跳轉,讓觀眾在不知情的情況下離開廣告插播時間
檢查使用者的跳轉廣告是否超過未觀看的廣告插播時間點。
如果有,請將觀眾帶回廣告插播時間點
Roku 進階範例仰賴遙控器按下
使用者跳轉 - 每次使用者按下前進按鈕時,
以您指定的秒數播放串流。維持不變
處理這次跳躍的方法也會檢查
會在廣告插播後或看完插播廣告,如果確實符合,就會把使用者
改為廣告插播時間點的開頭:
Function handleFastForward(player as Object, streamManager as Object, updatedTime As Integer)
previousAd = streamManager.getPreviousCuePoint(updatedTime)
If previousAd = Invalid or previousAd.hasPlayed
player.seek(updatedTime * 1000)
Else If previousAd.start > player.currentTime
player.isSnapback = True
player.timeAfterSnapback = updatedTime
player.seek(previousAd.start * 1000 + 1000)
End If
End Function
讓使用者回到原本的搜尋頁面
在您的 adBreakEnded
處理常式中,檢查先前的廣告
因回溯而播放中斷。如果是,請傳回
並將使用者導向他們想去的地方 (例如
因為該位置不是剛播放的廣告插播中間):
player.adBreakEnded = Function(adBreakInfo as Object)
If m.isSnapback
m.seek(m.timeAfterSnapback * 1000)
m.isSnapback = False
End If
End Function
除非另有註明,否則本頁面中的內容是採用創用 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 attempt to seek past it.\u003c/p\u003e\n"],["\u003cp\u003eWhen snapback is triggered, viewers are taken back to the ad and then returned to their original seek location after the ad completes.\u003c/p\u003e\n"],["\u003cp\u003eImplementing snapback involves checking for seeks past unwatched ad breaks and redirecting the viewer, then returning them to their desired location afterwards.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code snippets demonstrate how to implement snapback using the IMA DAI SDK, handling seek events and ad break endings.\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 snapack using the IMA DAI SDK, as demonstrated in our\n[Advanced Example](//github.com/googleads/googleads-ima-roku-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.\nThe Roku advanced sample relies on remote button presses for the\nuser to seek - each time the user presses the forward button, they\njump forward in the stream by a set number of seconds. The same\nmethod that handles this jump also checks to see if the jump\ntakes/ them past or into an ad break, and if it does, sends the user\nto the start of that ad break instead: \n\n Function handleFastForward(player as Object, streamManager as Object, updatedTime As Integer)\n previousAd = streamManager.getPreviousCuePoint(updatedTime)\n If previousAd = Invalid or previousAd.hasPlayed\n player.seek(updatedTime * 1000)\n Else If previousAd.start \u003e player.currentTime\n player.isSnapback = True\n player.timeAfterSnapback = updatedTime\n player.seek(previousAd.start * 1000 + 1000)\n End If\n End Function\n\nPut the user back to their original seek\n----------------------------------------\n\nIn your `adBreakEnded` handler, check to see if the previous ad\nbreak was played as the result of snapback. If so, return the\nuser to the place they were trying to seek to initially (as long\nas it wasn't the middle of the ad break that just played): \n\n player.adBreakEnded = Function(adBreakInfo as Object)\n If m.isSnapback\n m.seek(m.timeAfterSnapback * 1000)\n m.isSnapback = False\n End If\n End Function"]]