광고 스트림 북마크 저장 및 로드
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 가이드에서는 VOD 스트림에 동적 광고 삽입(DAI)을 사용할 때 IMA DAI SDK를 사용하여 북마크를 구현하는 방법을 보여줍니다.
여기서는 시작하기에 설명된 것과 같이 작동하는 IMA DAI 구현이 있다고 가정합니다.
북마크란 무엇인가요?
북마크는 콘텐츠 스트림의 특정 포인트를 저장한 다음 돌아가는 기능입니다. 사용자가 콘텐츠를 5분간 시청하고 동영상 스트림에서 나간 후 돌아온다고 가정하겠습니다. 북마크가 스트림 내 사용자의 위치를 저장하므로 스트림이 중단된 위치를 찾아내어 뷰어에 원활한 환경을 제공합니다.
DAI 북마크의 내부 작동 방식
DAI 스트림을 북마크할 때는 사용자가 동영상을 나가는 시점의 스트림 ID와 시간을 기록해야 합니다. 사용자가 돌아오면 스트림을 다시 요청하고 저장된 시간으로 탐색합니다. 요청된 스트림의 각 인스턴스에는 길이가 다른 광고 시점이 있을 수 있으므로 스트림 시간을 저장하는 것만으로는 작동하지 않습니다. 실제로는 동일한 콘텐츠 시간부터 계속 진행하는 것이 좋습니다.
전환 방법으로 해결하기
IMA DAI SDK는 지정된 스트림 시간의 콘텐츠 시간과 지정된 콘텐츠 시간의 스트림 시간을 요청하는 메서드 쌍을 제공합니다. 이러한 변환 메서드를 사용하면 북마크된 콘텐츠 시간을 저장한 다음 스트림의 새 인스턴스에서 해당하는 스트림 시간으로 탐색할 수 있습니다. 다음은 작동하는 북마크 구현을 보여주는 샘플 앱 링크를 포함한 접근 방식입니다.
광고 스트림 북마크 저장 및 로드
콘텐츠 플레이어가 일시중지되면 북마크를 저장합니다.
onPause() {
var bookmarkTime = Math.floor(
streamManager.contentTimeForStreamTime(videoElement.currentTime));
}
북마크 로드 중
스트림을 다시 요청할 때 북마크를 로드합니다.
function loadUrl(url) {
hls.on(Hls.Events.MANIFEST_PARSED, () => {
var startTime = 0;
if (bookmarkTime) {
var startTime = streamManager.streamTimeForContentTime(bookmarkTime);
// Seeking on load triggers the onSeekEnd event, so treat this seek as
// if it's snapback. Without this, resuming at a bookmark kicks you
// back to the ad before the bookmark.
isSnapback = true;
}
hls.startLoad(startTime);
videoElement.addEventListener('loadedmetadata', () => { videoElement.play(); });
});
hls.loadSource(url);
hls.attachMedia(videoElement);
}
샘플 앱
북마크 구현을 보려면 샘플 앱을 다운로드하세요.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-21(UTC)
[null,null,["최종 업데이트: 2025-08-21(UTC)"],[[["\u003cp\u003eThis guide explains how to implement bookmarking in video-on-demand (VOD) streams using the IMA DAI SDK for a seamless viewing experience when users return to previously watched content.\u003c/p\u003e\n"],["\u003cp\u003eBookmarking with DAI involves saving the content time, not the stream time, to ensure accurate resumption due to potential ad break variations.\u003c/p\u003e\n"],["\u003cp\u003eThe IMA DAI SDK provides methods \u003ccode\u003econtentTimeForStreamTime\u003c/code\u003e and \u003ccode\u003estreamTimeForContentTime\u003c/code\u003e to convert between stream and content time for bookmarking functionality.\u003c/p\u003e\n"],["\u003cp\u003eA sample app demonstrating a working bookmarking implementation is available for download and reference.\u003c/p\u003e\n"]]],[],null,["# Save and load ad stream bookmarks\n\nThis guide shows how to implement bookmarking using the IMA DAI SDK\nwhen using Dynamic Ad Insertion (DAI) for video-on-demand (VOD) streams.\nThis assumes a working IMA DAI implementation, such as the one presented in\n\n[Get Started](/interactive-media-ads/docs/sdks/html5/dai-quickstart).\n\n\nWhat is bookmarking?\n--------------------\n\nBookmarking is the ability to save and then return to a specific point\nin the content stream. Suppose a user watches five minutes of content,\nleaves the video stream, and then returns to it. Bookmarking saves the\nuser's position in the stream so the stream can pick up from where it\nleft off, providing a seamless experience to the viewer.\n\nDAI bookmarking under the hood\n------------------------------\n\nWhen bookmarking a DAI stream, you must record the stream id and time\nwhen the user leaves the video. When the user returns, re-request the\nstream and seek to the saved time. Since each instance of the requested\nstream can have ad breaks of different durations simply saving the stream\ntime won't work. What you really want to do is continue from the same\n**content time**.\n\nConversion methods to the rescue\n--------------------------------\n\nThe IMA DAI SDK provides a pair of methods to request the **content time**\nfor a given **stream time** and the **stream time** for a given **content\ntime** . Using these conversion methods you can store the bookmarked\n**content time** and then seek to the corresponding **stream time** in\nthe new instance of the stream. Here's the approach, including a link\nto a sample app that shows a working bookmarking implementation.\n\nSave and load ad stream bookmarks\n---------------------------------\n\nSave a bookmark when the content player is paused. \n\n onPause() {\n var bookmarkTime = Math.floor(\n streamManager.contentTimeForStreamTime(videoElement.currentTime));\n }\n\nLoading bookmarks\n-----------------\n\nLoad the bookmark when re-requesting a stream. \n\n function loadUrl(url) {\n hls.on(Hls.Events.MANIFEST_PARSED, () =\u003e {\n var startTime = 0;\n if (bookmarkTime) {\n var startTime = streamManager.streamTimeForContentTime(bookmarkTime);\n // Seeking on load triggers the onSeekEnd event, so treat this seek as\n // if it's snapback. Without this, resuming at a bookmark kicks you\n // back to the ad before the bookmark.\n isSnapback = true;\n }\n hls.startLoad(startTime);\n videoElement.addEventListener('loadedmetadata', () =\u003e { videoElement.play(); });\n });\n hls.loadSource(url);\n hls.attachMedia(videoElement);\n }\n\nSample app\n----------\n\n[Download the Sample app](//github.com/googleads/googleads-ima-html5-dai)\nto see a bookmarking implementation."]]