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

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

در اینجا نحوه پیاده سازی این گردش کار در IMA DAI SDK، همانطور که در AdvancedExample انجام می شود، آمده است.
جلوگیری از بی توجهی یک وقفه تبلیغاتی به دنبال
بررسی کنید که آیا کاربر جستجویی را انجام داده است که از یک وقفه تبلیغاتی تماشا نشده گذشته است یا خیر، و اگر چنین است، او را به وقفه تبلیغاتی برگردانید. برای مثال iOS Advanced، از تعامل کاربر با رابط کاربری خود استفاده کنید تا تشخیص دهید چه زمانی جستجو کرده است. زمان شروع جستجو را حفظ کنید تا بررسی کنید که آیا آنها از وقفه تبلیغاتی پخش نشده در جستجوی خود عبور کرده اند یا خیر. وقتی کاربر کنترلهای ویدیو را آزاد میکند، زمان فعلی او را با زمان آخرین وقفه تبلیغاتی مقایسه کنید. اگر وقفه آگهی بعد از زمان شروع جستجو (به این معنی است که کاربر از آن گذشته است) افتاد و هنوز پخش نشده است، آنها را به شروع استراحت جستجو کنید. همچنین، یک پرچم snapback تنظیم کنید تا بعداً در کنترل کننده کامل استراحت آگهی خود بررسی شود:
- (IBAction)videoControlsTouchStarted:(id)sender {
self.seekStartTime = self.contentPlayer.currentTime;
}
- (IBAction)videoControlsTouchEnded:(id)sender {
self.seekEndTime = CMTimeMake(self.progressBar.value, 1);
IMACuepoint *lastCuepoint =
[self.streamManager previousCuepointForStreamTime:CMTimeGetSeconds(self.seekEndTime)];
if (!lastCuepoint.played && (lastCuepoint.startTime > CMTimeGetSeconds(self.seekStartTime))) {
self.snapbackMode = YES
// Add 1 to the seek time to get the keyframe at the start of the ad to be your landing place.
[self.contentPlayer seekToTime:CMTimeMakeWithSeconds(lastCuepoint.startTime + 1, NSEC_PER_SEC)];
}
}
کاربر را به جستجوی اصلی خود برگردانید
در کنترلر با پایان شکست آگهی خود، بررسی کنید که آیا شکست قبلی در نتیجه snapback پخش شده است یا خیر. اگر چنین است، کاربر را به مکانی که در ابتدا میخواست به دنبال آن بود برگردانید (تا زمانی که اواسط وقفه تبلیغاتی پخش نشده باشد):
- (void)streamManager:(IMAStreamManager *)streamManager didReceiveAdEvent:(IMAAdEvent *)event {
switch (event.type) {
case kIMAAdEvent_AD_BREAK_ENDED: {
if (self.snapbackMode) {
self.snapbackMode = NO;
if (CMTimeCompare(self.seekEndTime, self.contentPlayer.currentTime)) {
[self.contentPlayer seekToTime:self.seekEndTime];
}
}
break;
}
}
}
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز 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, the feature 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 that bypass unwatched ads and using ad break event handlers to redirect the viewer accordingly.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code snippets demonstrate how to detect ad-skipping seeks and trigger the snapback functionality within the IMA DAI SDK.\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 the\n[AdvancedExample](//github.com/googleads/googleads-ima-ios-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.\nFor the iOS Advanced example, use the user's interaction with your UI\nto detect when they have run a seek. Preserve the seek start time to check\nif they've passed an unplayed ad break in their seek. When the user\nreleases the video controls, compare their current time to the time of\nthe most recent ad break. If the ad break falls after the seek start\ntime (meaning the user has jumped past it) and it hasn't yet been played,\nseek them back to the start of the ad break. Also, set a snapback flag\nto check later in your ad break complete handler: \n\n - (IBAction)videoControlsTouchStarted:(id)sender {\n self.seekStartTime = self.contentPlayer.currentTime;\n }\n\n - (IBAction)videoControlsTouchEnded:(id)sender {\n self.seekEndTime = CMTimeMake(self.progressBar.value, 1);\n IMACuepoint *lastCuepoint =\n [self.streamManager previousCuepointForStreamTime:CMTimeGetSeconds(self.seekEndTime)];\n if (!lastCuepoint.played && (lastCuepoint.startTime \u003e CMTimeGetSeconds(self.seekStartTime))) {\n self.snapbackMode = YES\n // Add 1 to the seek time to get the keyframe at the start of the ad to be your landing place.\n [self.contentPlayer seekToTime:CMTimeMakeWithSeconds(lastCuepoint.startTime + 1, NSEC_PER_SEC)];\n }\n }\n\nPut the user back to their original seek\n----------------------------------------\n\nIn your ad-break-ended handler, check to see if the previous\nbreak was played as the result of snapback. If so, return the user\nto the place they were trying to seek to initially (as long as it\nwasn't the middle of the ad break that just played): \n\n - (void)streamManager:(IMAStreamManager *)streamManager didReceiveAdEvent:(IMAAdEvent *)event {\n switch (event.type) {\n case kIMAAdEvent_AD_BREAK_ENDED: {\n if (self.snapbackMode) {\n self.snapbackMode = NO;\n if (CMTimeCompare(self.seekEndTime, self.contentPlayer.currentTime)) {\n [self.contentPlayer seekToTime:self.seekEndTime];\n }\n }\n break;\n }\n }\n }"]]