بازگشت به وقفه تبلیغاتی رد شده، بازگشت به وقفه تبلیغاتی رد شده، بازگشت به وقفه تبلیغاتی رد شده، بازگشت به وقفه تبلیغاتی رد شده
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
بهعنوان یک ناشر ویدیو، ممکن است بخواهید از جستجوی بینندگان خود در تبلیغات میانپول خود جلوگیری کنید. وقتی کاربر به دنبال وقفه تبلیغاتی است، میتوانید او را به ابتدای آن وقفه تبلیغاتی برگردانید و پس از اتمام آن وقفه تبلیغاتی، او را به مکان جستجوی خود برگردانید. این ویژگی "snapback" نام دارد.
به عنوان مثال، نمودار زیر را ببینید. بیننده شما در حال تماشای یک ویدیو است و تصمیم می گیرد از نقطه 5 دقیقه تا 15 دقیقه را جستجو کند. با این حال، یک وقفه تبلیغاتی در حد 10 دقیقه وجود دارد که میخواهید قبل از اینکه بتوانند محتوا را بعد از آن تماشا کنند، آن را تماشا کنند:

برای نمایش این استراحت تبلیغاتی، مراحل زیر را انجام دهید:
- بررسی کنید که آیا کاربر جستجویی انجام داده است که از یک وقفه تبلیغاتی تماشا نشده عبور کرده است یا خیر، و اگر چنین است، او را به استراحت تبلیغاتی برگردانید.
- پس از اتمام وقفه تبلیغاتی، آنها را به جستجوی اصلی خود برگردانید.
در شکل نمودار، به شکل زیر است:

در اینجا نحوه پیاده سازی snapback با استفاده از IMA DAI SDK، همانطور که در Advanced Example نشان داده شده است، آمده است.
جلوگیری از بی توجهی یک وقفه تبلیغاتی به دنبال
بررسی کنید که آیا کاربر جستجویی را انجام داده است که از یک وقفه تبلیغاتی تماشا نشده گذشته است یا خیر، و اگر چنین است، او را به وقفه تبلیغاتی برگردانید. در HTML5 SDK، یک شنونده رویداد را روی رویداد seeked
پخش کننده محتوا تنظیم کنید تا onSeekEnd()
را فعال کند. این روش (در زیر ارائه شده است) نقطه نشانه را قبل از زمان جستجوی کاربر بررسی می کند. اگر پخش نشد، به جای نقطه جستجوی اولیه مورد نظر، به ابتدای آن استراحت تبلیغاتی بگردید و آن نقطه جستجوی مورد نظر را در snapForwardTime
ذخیره کنید.
function onSeekEnd() {
if (isLiveStream) { return; }
if (isSnapback) {
isSnapback = false;
return;
}
var currentTime = videoElement.currentTime;
var previousCuePoint =
streamManager.previousCuePointForStreamTime(currentTime);
if (previousCuePoint && !previousCuePoint.played) {
isSnapback = true;
snapForwardTime = currentTime;
videoElement.currentTime = previousCuePoint.start;
}
کاربر را به جستجوی اصلی خود برگردانید
اکنون وقتی یک رویداد AD_BREAK_ENDED
دریافت میکنید، بررسی کنید که آیا snapForwardTime
تنظیم شده است یا خیر. اگر چنین است، کاربر را به آن نقطه از جریان ببرید، زیرا وقفه تبلیغاتی که او به تازگی تماشا کرده است، نتیجه snapback بوده است:
function onAdBreakEnded(e) {
videoElement.controls = true;
clickElement.style.display = 'none';
adUiDiv.style.display = 'none';
if (snapForwardTime && snapForwardTime > videoElement.currentTime) {
videoElement.currentTime = snapForwardTime;
snapForwardTime = null;
}
}
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده 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, snapback 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 past unwatched ad breaks and redirecting the viewer accordingly using the IMA DAI SDK.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use the \u003ccode\u003eseeked\u003c/code\u003e event and \u003ccode\u003epreviousCuePointForStreamTime\u003c/code\u003e function to detect and manage snapback scenarios within their video players.\u003c/p\u003e\n"],["\u003cp\u003eAfter an ad break initiated by snapback, the \u003ccode\u003eAD_BREAK_ENDED\u003c/code\u003e event and \u003ccode\u003esnapForwardTime\u003c/code\u003e variable are used to return the viewer to their original seek position.\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 snapback using the IMA DAI SDK, as demonstrated in\n[Advanced Example](https://github.com/googleads/googleads-ima-html5-dai/tree/master/hls_js/advanced).\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.\nIn the HTML5 SDK, set an event listener on the content player's `seeked` event\nto trigger `onSeekEnd()`. That method (presented below) checks the cue point\nprior to the user's seek time. If it is unplayed, seek to the beginning of that\nad break instead of their initial desired seek point, and save that desired\nseek point in `snapForwardTime`. \n\n function onSeekEnd() {\n if (isLiveStream) { return; }\n if (isSnapback) {\n isSnapback = false;\n return;\n }\n var currentTime = videoElement.currentTime;\n var previousCuePoint =\n streamManager.previousCuePointForStreamTime(currentTime);\n if (previousCuePoint && !previousCuePoint.played) {\n isSnapback = true;\n snapForwardTime = currentTime;\n videoElement.currentTime = previousCuePoint.start;\n }\n\nPut the user back to their original seek\n----------------------------------------\n\nNow when you get an `AD_BREAK_ENDED` event, check to see if `snapForwardTime`\nis set. If so, take the user to that point in the stream, because the ad\nbreak they just watched was the result of snapback: \n\n function onAdBreakEnded(e) {\n videoElement.controls = true;\n clickElement.style.display = 'none';\n adUiDiv.style.display = 'none';\n if (snapForwardTime && snapForwardTime \u003e videoElement.currentTime) {\n videoElement.currentTime = snapForwardTime;\n snapForwardTime = null;\n }\n }"]]