건너뛴 광고 시점으로 돌아가기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
동영상 게시자는
미드롤 광고를 지나칠 수 있습니다 사용자가 광고 시점 지나를 검색하면
광고 시간의 시작 부분으로 되돌린 다음
탐색 위치로 이동할 수 있습니다. 이
'스냅백'이라고 부릅니다.
예를 들어 아래 다이어그램을 참조하세요. 시청자가 동영상을 시청하고 있을 때
5분 표시에서 15분 표시까지 탐색하기로 결정합니다.
그러나 원하는 10분 표시 시점에 광고 시점이
다음 콘텐츠를 시청하기 전에 미리 볼 수 있습니다.

이 광고 시점을 표시하려면 다음 단계를 따르세요.
- 사용자가 시청하지 않은 광고 시점을 넘어서 탐색했는지 확인합니다.
그렇다면 광고 시점으로 돌아가세요.
- 광고 시점이 완료되면 원래 탐색으로 되돌립니다.
이를 다이어그램 형식으로 표현하면 다음과 같습니다.

이 워크플로를 IMA DAI SDK에서 구현하는 방법은
AdvancedExample.
탐색이 광고 시점을 시청하지 않은 상태로 남겨두지 않도록 방지
사용자가 시청하지 않은 광고 시점을 지나 탐색을 실행했는지 확인합니다.
그렇다면 광고 시점으로 돌아가세요.
Android SDK에서 PlayerControl
객체를 사용하여 탐색을 감지합니다.
사용자가 탐색을 하면 onSeek()
메서드
SampleAdsWrapper
에서 구현한 SampleHlsVideoPlayerCallback
입니다.
이 메서드 (아래에 표시됨)는 사용자가
찾을 수 있습니다. 재생되지 않는 경우 광고 시점의 시작 부분 탐색
기존 탐색 지점 대신 원하는 탐색 지점을
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 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-21(UTC)
[null,null,["최종 업데이트: 2025-08-21(UTC)"],[[["\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 }"]]