Co-Watching API 구현

Co-Watching API는 여러 사람의 회의 환경을 관리합니다. 사용자의 참여를 유도할 수 있습니다.

이 가이드에서는 Co-Watching API를 구현하는 방법을 설명합니다.

시작하기

Co-Watching API를 사용하려면 먼저 Meet 부가기능을 참조하세요. 한 번 해당 단계를 완료하면 Co-Watching API를 사용할 수 있습니다. 새 부가기능 내에서 액세스할 수 있습니다

Co-Watching API를 사용하려면 먼저 AddonSession 공동 활동의 진입점 역할을 합니다.

TypeScript

const session = await window.meet.addon.createAddonSession({
    cloudProjectNumber: "CLOUD_PROJECT_NUMBER",
});

CoWatchingClient를 만드는 방법

시작하려면 createCoWatchingClient 드림 AddonSession에서 가져옴

CoWatchingCient를 만들려면 다음을 호출합니다. AddonSession.createCoWatchingClient 메서드를 사용하고 CoWatchingDelegate입니다.

CoWatchingDelegate는 Co-Watching API가 새 상태를 사용할 수 있을 때마다 애플리케이션을 호출합니다 CoWatchingDelegate.onCoWatchingStateChanged 드림 메서드가 호출되면 애플리케이션이 즉시 새 상태를 적용합니다.

다음 코드 샘플은 Co-Watching API를 사용하는 방법을 보여줍니다.

TypeScript

 const coWatchingClient = await addonSession.createCoWatchingClient({
    activityTitle: "ACTIVITY_TITLE",
    onCoWatchingStateQuery() {
      // This function should return the current state of your CoWatching activity
      return getMyApplicationCoWatchingState();
    },
    onCoWatchingStateChanged(coWatchingState: CoWatchingState) {
      // This function should apply newState to your ongoing CoWatching activity
    },
  });

ACTIVITY_TITLE을 활동의 미디어 제목으로 바꿉니다.

현재 상태 관리

사용자가 애플리케이션에서 액션을 취할 때는 애플리케이션이 제공된 API 메서드를 즉시 호출합니다.

이러한 메서드는 중요한 이벤트에 대한 응답으로만 호출해야 합니다. 대상 예를 들어 앱에서 플레이를 진행할 때마다 호출할 필요는 없습니다. 있습니다. 위에서 만든 CoWatchingDelegate가 업데이트를 처리합니다. 배치할 수 있습니다.

다음 방법을 사용하여 공동 시청 상태를 관리할 수 있습니다.