الرجوع إلى فاصل إعلاني تم تخطّيه
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
وبصفتك ناشر فيديو، قد تحتاج إلى منع المشاهدين من
تخطّي الإعلانات أثناء التشغيل عندما يتخطّى المستخدم الفاصل الإعلاني
يمكنك إعادتها إلى بداية الفاصل الإعلاني، ثم
إلى موقع البحث بعد اكتمال ذلك الفاصل الإعلاني. هذا النمط
تسمى "Snapback".
كمثال، انظر الرسم التخطيطي أدناه. إذا كان المستخدم يشاهد فيديو
ويقرر الانتقال من علامة 5 دقائق إلى 15 دقيقة.
ومع ذلك، هناك فاصل إعلاني عند الوصول إلى علامة الـ 10 دقائق التي تريد
ليتمكّنوا من مشاهدة المحتوى بعد انتهائه:

لعرض هذا الفاصل الإعلاني، اتّبِع الخطوات التالية:
- تحقّق مما إذا كان المستخدم قد أجرى عملية بحث تجاوزت فاصل إعلاني لم تتم مشاهدته.
وفي هذه الحالة، ارجع إلى الفاصل الإعلاني.
- بعد اكتمال الفاصل الإعلاني، يمكنك إعادته إلى موضعه الأصلي.
وفي شكل الرسم التخطيطي، يبدو ذلك كما يلي:

في ما يلي طريقة تنفيذ العودة إلى الحالة السابقة باستخدام حزمة تطوير البرامج لإدراج إعلان ديناميكي لإعلانات الوسائط التفاعلية، كما هو موضّح في
مثال متقدم.
منع التمرير حتى لا تتم مشاهدة فاصل إعلاني
تحقّق مما إذا كان المستخدم قد أجرى عملية بحث تجاوزت فاصل إعلاني لم تتم مشاهدته.
وفي هذه الحالة، ارجع إلى الفاصل الإعلاني.
في حزمة 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
تم تعيينها. إذا كان الأمر كذلك، فوجِّه المستخدم إلى تلك المرحلة من البث، لأن الإعلان
الاستراحة التي شاهدها للتو كانت نتيجة العودة إلى المحتوى السابق:
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 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 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, 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 }"]]