儲存及載入廣告串流書籤
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本指南說明如何使用 IMA DAI SDK 導入書籤功能
在隨選影片 (VOD) 串流中使用動態廣告插播 (DAI) 時。
本文會假設 IMA DAI 導入成功,例如
開始使用。
什麼是書籤?
書籤可讓使用者儲存並回到特定時間點
內容串流中。假設某位使用者觀看了五分鐘的內容
離開影片串流,然後返回該串流這時書籤功能會儲存使用者在該串流中停止的位置,如此該串流就能從上次停止的地方繼續播放,方便觀眾順暢觀賞內容。
DAI 內部書籤
將 DAI 串流加入書籤時,您必須記錄串流 ID 和時間
使用者離開影片時。當使用者回訪時,請重新提出要求
播放串流,然後跳轉至已儲存的時間。由於要求的串流每個例項可能有不同長度的廣告插播,因此單純儲存串流時間將無法運作。但不打算想要做什麼
內容時間。
因應之道的轉換方法
IMA DAI SDK 提供一組方法,用來請求內容時間
特定內容的串流時間及串流時間的內容
時間。使用這些轉換方法,您就能將
內容時間,然後跳轉至對應的串流時間,
新的串流執行個體做法如下,包括連結
以便在某個範例應用程式中,顯示可正常運作的書籤。
正在儲存書籤
在活動暫停時儲存書籤。
Saves the current time as a bookmark in the current video.
Function saveBookmarkTime(player as Object, streamManager as Object) as Void
m.videos[player.video.index].bookmarkTime =
streamManager.getContentTime(player.currentTime * 1000)
End Function
正在載入書籤
在重新要求直播時載入書籤。這個容器是將容器
VideoStreamPlayer
介面。
player.loadUrl = Function(streamInfo as Object)
...
If m.video.bookmarkTime > 0
streamTime = m.streamManager.getStreamTime(m.video.bookmarkTime)
m.videoPlayer.seek(streamTime)
End If
End Function
範例應用程式
範例應用程式
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-21 (世界標準時間)。
[null,null,["上次更新時間:2025-08-21 (世界標準時間)。"],[[["\u003cp\u003eThis guide explains how to implement bookmarking in video-on-demand (VOD) streams using the IMA DAI SDK for Roku, allowing users to resume playback from where they left off.\u003c/p\u003e\n"],["\u003cp\u003eBookmarking with DAI involves saving the content time, not just the stream time, to ensure accurate resumption due to potential ad break variations.\u003c/p\u003e\n"],["\u003cp\u003eThe IMA DAI SDK provides methods to convert between stream time and content time, enabling the storage and retrieval of bookmarks based on content progress.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can implement bookmarking by saving the content time when the video is paused and retrieving it to seek to the corresponding stream time when the stream is reloaded.\u003c/p\u003e\n"],["\u003cp\u003eA sample app demonstrating a working bookmarking implementation is available on GitHub for reference and further exploration.\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\n[Get Started](/interactive-media-ads/docs/sdks/roku/dai).\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\nSaving bookmarks\n----------------\n\nSave a bookmark when the Activity is paused. \n\n Saves the current time as a bookmark in the current video.\n Function saveBookmarkTime(player as Object, streamManager as Object) as Void\n m.videos[player.video.index].bookmarkTime =\n streamManager.getContentTime(player.currentTime * 1000)\n End Function\n\nLoading bookmarks\n-----------------\n\nLoad the bookmark when re-requesting a stream. It's part of implementing\nthe `VideoStreamPlayer` interface. \n\n player.loadUrl = Function(streamInfo as Object)\n ...\n If m.video.bookmarkTime \u003e 0\n streamTime = m.streamManager.getStreamTime(m.video.bookmarkTime)\n m.videoPlayer.seek(streamTime)\n End If\n End Function\n\nSample app\n----------\n\n[Sample app](//github.com/googleads/googleads-ima-roku-dai)"]]