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

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

في ما يلي كيفية تنفيذ سير العمل هذا في حزمة تطوير البرامج لإدراج إعلان ديناميكي لإعلانات الوسائط التفاعلية، كما تم في
AdvancedExample.
منع التمرير حتى لا تتم مشاهدة فاصل إعلاني
تحقّق مما إذا كان المستخدم قد أجرى عملية بحث تجاوزت فاصل إعلاني لم تتم مشاهدته.
وفي هذه الحالة، ارجع إلى الفاصل الإعلاني.
في حزمة تطوير البرامج (SDK) لنظام التشغيل Android، استخدِم كائن PlayerControl
لرصد التقديم/الترجيع.
عندما يبحث المستخدم، فعِّل طريقة onSeek()
تم تنفيذ SampleHlsVideoPlayerCallback
من قِبل SampleAdsWrapper
.
تتحقق هذه الطريقة (الموضحة أدناه) من نقطة عرض الإعلانات قبل هدف
ابحث عن الوقت. إذا لم يتم تشغيله، انتقِل إلى بداية الفاصل الإعلاني.
بدلاً من نقطة التقديم المطلوبة الأولية، وحفظ مستوى التقديم/الترجيع المطلوب
في snapBackTime
.
@Override
public void onSeek(int timeMillis) {
double timeToSeek = timeMillis;
if (streamManager != null) {
CuePoint cuePoint =
streamManager.getPreviousCuePointForStreamTime(timeMillis / 1000);
if (cuePoint != null && !cuePoint.isPlayed()) {
snapBackTime = timeToSeek / 1000.0; // Update snapback time.
// Missed cue point, so snap back to the beginning of cue point.
timeToSeek = cuePoint.getStartTime() * 1000;
videoPlayer.seek(Math.round(timeToSeek));
videoPlayer.setCanSeek(false);
return;
}
}
videoPlayer.seek(Math.round(timeToSeek));
}
إعادة المستخدم إلى هدفه الأصلي
عندما تحصل على حدث onAdBreakEnded
الآن، تحقّق ممّا إذا كان snapBackTime
تم تعيينها. إذا كان الأمر كذلك، فوجِّه المستخدم إلى تلك المرحلة من البث، لأن الإعلان
الاستراحة التي شاهدها للتو كانت نتيجة العودة إلى المحتوى السابق:
@Override
public void onAdBreakEnded() {
// Re-enable player controls.
videoPlayer.setCanSeek(true);
videoPlayer.enableControls(true);
if (snapBackTime > 0) {
videoPlayer.seek(Math.round(snapBackTime * 1000));
}
snapBackTime = 0;
}
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص 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 redirecting them to the ad and then returning them to their intended location.\u003c/p\u003e\n"],["\u003cp\u003eThis feature ensures ad completion before viewers proceed to the content they seek.\u003c/p\u003e\n"],["\u003cp\u003eSnapback functionality is implemented through the IMA DAI SDK, as demonstrated in the AdvancedExample.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves identifying unwatched ad breaks and redirecting the viewer and then resuming playback at the target point after the ad.\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\n[AdvancedExample](//github.com/googleads/googleads-ima-android-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.\nIn the Android SDK, use the `PlayerControl` object to detect seeking.\nWhen the user seeks, trigger the `onSeek()` method of the\n`SampleHlsVideoPlayerCallback` implemented by `SampleAdsWrapper`.\nThat method (presented below) checks the cue point prior to the user's\nseek time. If it is unplayed, seek to the beginning of that ad break\ninstead of their initial desired seek point, and save that desired seek\npoint in `snapBackTime`. \n\n @Override\n public void onSeek(int timeMillis) {\n double timeToSeek = timeMillis;\n if (streamManager != null) {\n CuePoint cuePoint =\n streamManager.getPreviousCuePointForStreamTime(timeMillis / 1000);\n if (cuePoint != null && !cuePoint.isPlayed()) {\n snapBackTime = timeToSeek / 1000.0; // Update snapback time.\n // Missed cue point, so snap back to the beginning of cue point.\n timeToSeek = cuePoint.getStartTime() * 1000;\n videoPlayer.seek(Math.round(timeToSeek));\n videoPlayer.setCanSeek(false);\n return;\n }\n }\n videoPlayer.seek(Math.round(timeToSeek));\n }\n\nPut the user back to their original seek\n----------------------------------------\n\nNow when you get an `onAdBreakEnded` event, check to see if `snapBackTime`\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 @Override\n public void onAdBreakEnded() {\n // Re-enable player controls.\n videoPlayer.setCanSeek(true);\n videoPlayer.enableControls(true);\n if (snapBackTime \u003e 0) {\n videoPlayer.seek(Math.round(snapBackTime * 1000));\n }\n snapBackTime = 0;\n }"]]