スキップしたミッドロール挿入点に戻る
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
動画のパブリッシャーは、視聴者が
ミッドロール広告をスキップできますユーザーがミッドロール挿入点を超えてシークすると、
その広告ブレークの先頭に戻って
そのミッドロール挿入点が完了した後に、シークする位置にユーザーが移動します。この
「スナップバック」と呼ばれます。
例として、以下の図をご覧ください。視聴者が動画を視聴している
5 分の時点から 15 分の時点までシークします。
ただし、希望する 10 分の時点でミッドロール挿入点を
ユーザーが次のコンテンツを視聴する前に、次の動画を視聴するようユーザーに促すことができます。

このミッドロール挿入点を表示する方法は次のとおりです。
- ユーザーがシークを実行して、視聴していないミッドロール挿入点を通過したかどうかを確認します。
その場合はミッドロール挿入点に戻ります
- ミッドロール挿入点が完了したら、元の移動に戻ります。
図形式では、次のようになります。

このワークフローを IMA DAI SDK で実装する方法は次のとおりです。
AdvancedExample をご覧ください。
シークで広告ブレークが再生されないままにならないようにする
ユーザーが再生していない広告ブレークを通過したシークをユーザーが実行したかどうかを確認します。
その場合はミッドロール挿入点に戻ります
iOS Advanced の例では、ユーザーの UI 操作を使用します。
シークを実行したことを検出しますシーク開始時間を保持して、シークで未再生のミッドロール挿入点を超えたかどうかを確認します。ユーザーが
は、動画コントロールを離し、現在の時刻を、
最新のミッドロール挿入点が表示されます。シーク開始後にミッドロール挿入点が発生した場合
(ユーザーが飛び越して過ぎた)が、まだ再生されていない場合、
広告ブレークの先頭までシークします。さらにスナップバックフラグも
広告ブレーク完了ハンドラで後で確認する手順は次のとおりです。
- (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)];
}
}
ユーザーを元の検索モードに戻す
広告ブレークの終了ハンドラで、前のスライドの
スナップバックの結果として再生されました。「はい」の場合は、ユーザーに
探していた場所に戻ることができます(ただし、
再生されたミッドロール挿入点の途中ではなかった場合):
- (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;
}
}
}
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 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 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 }"]]