CoWatchingDelegate 是 Co-Watching API 在有新狀態可用時更新應用程式的方式。預期在呼叫 onCoWatchingStateChanged() 方法時,應用程式會立即套用新狀態。
以下程式碼範例說明如何使用 Co-Watching API:
TypeScript
constcoWatchingClient=awaitaddonSession.createCoWatchingClient({activityTitle:"ACTIVITY_TITLE",onCoWatchingStateQuery(){// This function should return the current state of your CoWatching activityreturngetMyApplicationCoWatchingState();},onCoWatchingStateChanged(coWatchingState:CoWatchingState){// This function should apply newState to your ongoing CoWatching activity},});
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-12-21 (世界標準時間)。"],[[["The Co-Watching API enables shared media experiences within Google Meet add-ons, allowing multiple participants to watch or listen to content synchronously."],["To utilize this API, developers need to deploy a Meet add-on and initiate a Co-Watching client using an `AddonSession` object and a `CoWatchingDelegate` for state management."],["The `CoWatchingDelegate` object is crucial for handling state updates and ensuring the application reflects the current state of the co-watching activity."],["Developers can control the co-watching experience through methods like `notifyPauseState()`, `notifySeekToTimestamp()`, and `notifySwitchToMedia()` to manage playback, seeking, and media changes."],["While previously in Early Access, the program is now closed to new sign-ups."]]],["The Co-Watching API enables synchronized content viewing in apps. Implementation requires deploying a Meet add-on and using an `AddonSession` object, initiated with a Google Cloud project number. A `CoWatchingClient` is created, linked to a `CoWatchingDelegate` that updates the app with new states. The app uses methods like `notifyBuffering()`, `notifyPauseState()`, `notifyPlayoutRate()`, `notifyReady()`, `notifySeekToTimestamp()`, and `notifySwitchToMedia()` to manage the co-watching state based on user actions. The Early Access Program for this feature is closed.\n"]]