กลับไปที่ช่วงพักโฆษณาที่ข้าม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ในฐานะผู้เผยแพร่วิดีโอ คุณอาจต้องการป้องกันไม่ให้ผู้ชม
ที่ผ่านโฆษณาตอนกลางของคุณ เมื่อผู้ใช้กรอผ่านช่วงพักโฆษณา
คุณสามารถนำหน่วยโฆษณากลับไปยังจุดเริ่มต้นของช่วงพักโฆษณา แล้วค่อยกลับมาที่หน้านี้
ไปยังตำแหน่งที่ผู้ใช้ค้นหาหลังจากช่วงพักโฆษณาสิ้นสุดลง ช่วงเวลานี้
ที่เรียกว่า "snapback"
โปรดดูแผนภาพด้านล่างเป็นตัวอย่าง ผู้ชมของคุณกำลังดูวิดีโอ
และตัดสินใจค้นหาจากช่วง 5 นาทีจนถึง 15 นาที
อย่างไรก็ตาม มีช่วงพักโฆษณาที่ 10 นาทีซึ่งคุณต้องการให้ผู้ชมดูก่อนที่จะดูเนื้อหาต่อได้

หากต้องการแสดงช่วงพักโฆษณา ให้ทำตามขั้นตอนต่อไปนี้
- ตรวจสอบว่าผู้ใช้ทำการค้นหาที่ข้ามผ่านช่วงพักโฆษณาที่ยังไม่ได้ดูหรือไม่
ให้ย้อนกลับไปที่ช่วงพักโฆษณา
- หลังจากช่วงพักโฆษณาสิ้นสุดลง ให้นำโฆษณากลับไปยังกรอวิดีโอเดิม
ในรูปแบบแผนภาพ จะมีลักษณะดังนี้

ต่อไปนี้เป็นวิธีติดตั้ง Snapack โดยใช้ IMA DAI SDK ดังที่แสดงใน
ตัวอย่างขั้นสูง
ป้องกันไม่ให้ระบบเลิกดูช่วงพักโฆษณา
ตรวจสอบว่าผู้ใช้กรอผ่านช่วงพักโฆษณาที่ไม่ได้ดูหรือไม่ หากใช่ ให้นําผู้ใช้กลับไปยังช่วงพักโฆษณา
ตัวอย่างขั้นสูงของ 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
ให้ตรวจสอบว่าโฆษณาก่อนหน้า
เล่น break จากผลของ Snapback ในกรณีนี้ ให้ส่งคืน
ไปยังสถานที่ที่พวกเขาพยายามจะเสาะหา ในตอนแรก (
เพราะไม่ได้อยู่ระหว่างช่วงพักโฆษณาที่เพิ่งเล่นไป)
player.adBreakEnded = Function(adBreakInfo as Object)
If m.isSnapback
m.seek(m.timeAfterSnapback * 1000)
m.isSnapback = False
End If
End Function
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-21 UTC
[null,null,["อัปเดตล่าสุด 2025-08-21 UTC"],[[["\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"]]