使用 Meet 外掛程式進行協作
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
會議參與者可以透過 Google Meet 外掛程式活動進行協作。協作活動開始後,所有會議參與者都會收到活動進行中的通知。
這則通知會根據外掛程式的可用性和安裝狀態調整內容:
使用者加入活動時,系統會載入含有外掛程式內容的 iframe。您可以自訂新加入者應在主畫面或側邊面板中開啟協作活動。
開始活動
活動是透過呼叫 startActivity()
方法啟動,該方法會使用 ActivityStartingState
介面。
步驟 1 (選用):外掛程式設定活動的起始狀態
ActivityStartingState
包含外掛程式的初始狀態資訊,參與者接受活動邀請時會使用這些資訊。
外掛程式可以在活動開始前或期間隨時呼叫 setActivityStartingState()
方法,設定或更新 ActivityStartingState
。如果 ActivityStartingState
專門在對 startActivity()
的呼叫中設定,則可以省略對 setActivityStartingState()
的呼叫。
步驟 2:外掛程式啟動活動
當外掛程式在 MeetSidePanelClient
上呼叫 startActivity()
方法時,活動就會開始。startActivity()
方法會採用 ActivityStartingState
物件做為參數,因此可以呼叫 startActivity()
,而不必呼叫 setActivityStartingState()
。
使用者完成內容選取並準備開始活動後,請在外掛程式中呼叫 startActivity()
方法,如下所示:
sidePanelClient.startActivity({
mainStageUrl: "https://app.example.com/mainstage",
additionalData: JSON.stringify({
// State to send to participants.
})
});
呼叫 startActivity()
方法時,Meet 會執行下列動作:
步驟 3:取得活動的起始狀態
使用者加入活動時,系統會根據 ActivityStartingState
將外掛程式載入主舞台或側邊面板。
您可以使用 additionalData
屬性,與加入活動的使用者分享初始資料 (也稱為狀態)。初始化 MainStageClient
或 SidePanelClient
後,即可呼叫 getActivityStartingState()
方法來擷取 additionalData
屬性。
const startingState = client.getActivityStartingState();
const additionalData = JSON.parse(startingState.additionalData);
步驟 4 (選用):在活動中分享外掛程式狀態
您也可以在活動進行期間與其他使用者分享狀態。您可以透過下列兩種方式共用狀態:
範例:GitHub 上的動畫外掛程式
GitHub 上的「Animation」範例外掛程式包含外掛程式中的協作功能。本指南的步驟 1 不包含在範例中。相反地,當外掛程式啟動器點選側邊面板中的「Start the Animation」按鈕時,系統會呼叫 startActivity()
方法 (步驟 2),並以使用者選取的顏色填入起始狀態。活動開始後,主要階段會呼叫 getActivityStartingState()
方法 (步驟 3) 來擷取起始狀態。由於這個範例外掛程式的活動期間,參與者不會共用狀態 (所選顏色),因此省略步驟 4。不過,個別使用者可以選取顏色來變更自己的狀態,並使用 frame-to-frame 訊息,將狀態從側邊面板影格傳送至主要影格。
限制
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["# Collaborate using a Meet add-on\n\nParticipants in a meeting can work collaboratively on a\nGoogle Meet add-on activity. When a collaborative activity starts,\nall participants in the meeting receive a notification that the activity is\nongoing.\n\nThis notification is adapted to the availability and installation status of the\nadd-on:\n\n- **If the participant has the add-on installed**:\n They can join the activity.\n\n- **If the participant doesn't have the add-on\n installed**: They're directed to install the\n add-on.\n\n- **If the add-on isn't available for the\n participant's platform**: They're informed that they can't join the activity\n using their current device.\n\nWhen a user joins the activity they will load their own iframes with your\nadd-on content. You can customize whether new joiners\nshould open the collaborative activity in the main stage or side panel.\n\nStart the activity\n------------------\n\nAn activity is started by calling the\n[`startActivity()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetaddonclient.startactivity)\nmethod, which uses the\n[`ActivityStartingState`](/workspace/meet/add-ons/reference/websdk/addon_sdk.activitystartingstate)\ninterface.\n\n### Step 1 (Optional): The add-on sets the activity starting state\n\nThe [`ActivityStartingState`](/workspace/meet/add-ons/reference/websdk/addon_sdk.activitystartingstate)\ncontains information about the initial state of the\nadd-on that's used when the participant accepts the\ninvitation to join the activity.\n\nThe add-on can set or update the\n`ActivityStartingState` by calling the [`setActivityStartingState()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetaddonclient.setactivitystartingstate)\nmethod anytime before or during the activity. Calls to\n`setActivityStartingState()` can be omitted if the `ActivityStartingState` is\nexclusively set in the call to `startActivity()`.\n\n### Step 2: The add-on starts the activity\n\nThe activity begins when the add-on calls the\n[`startActivity()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetaddonclient.startactivity)\nmethod on the [`MeetSidePanelClient`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetsidepanelclient).\nThe `startActivity()` method takes an `ActivityStartingState` object as a\nparameter, so `startActivity()` can be called instead of calling\n`setActivityStartingState()`.\n\nOnce the user completes the content selection and is ready to start an activity,\ncall the `startActivity()` method in your add-on as\nfollows: \n\n sidePanelClient.startActivity({\n mainStageUrl: \"https://app.example.com/mainstage\",\n additionalData: JSON.stringify({\n // State to send to participants.\n })\n });\n\nWhen `startActivity()` method is invoked, Meet performs the\nfollowing actions:\n\n- **For other participants**: Meet shows a notification that\n the activity is ongoing.\n\n- **For the initiator** : If a main stage URL was specified in the\n `ActivityStartingState`, Meet opens the main stage using\n the URL from the `ActivityStartingState`.\n\n### Step 3: Get the activity starting state\n\nWhen a user joins the activity, they load your add-on\ninto the main stage or side panel depending on the `ActivityStartingState`.\n\nWith the `additionalData` property, you can share initial data (also referred to\nas state) with users joining the activity. After [initializing a\n`MainStageClient` or `SidePanelClient`](/workspace/meet/add-ons/guides/get-client), you\ncan call the\n[`getActivityStartingState()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetaddonclient.getactivitystartingstate)\nmethod to retrieve the `additionalData` property. \n\n const startingState = client.getActivityStartingState();\n const additionalData = JSON.parse(startingState.additionalData);\n\n### Step 4 (Optional): Share add-on state in an activity\n\nYou may also share state between users while the activity is ongoing. You can\nshare state in two ways:\n\n- Handle it yourself by authoring your own synchronization backend.\n- Use the [Co-Doing API](/workspace/meet/add-ons/guides/use-CoDoingAPI), which is a convenient and fast way to share arbitrary data between users.\n\nExample: Animation add-on on GitHub\n-----------------------------------\n\nThe [\"Animation\" sample add-on on GitHub](https://github.com/googleworkspace/meet/tree/3311b735550b8927c8b7ef2c6d06f768d9fe0476/addons-web-sdk/samples/animation-next-js)\nincludes collaboration in an add-on. [Step 1](#set-state)\nfrom this guide is not included in the sample. Instead, when the\nadd-on initiator clicks the\n[\"Start the Animation\" button](https://github.com/googleworkspace/meet/blob/3311b735550b8927c8b7ef2c6d06f768d9fe0476/addons-web-sdk/samples/animation-next-js/src/app/sidepanel/page.tsx#L72)\nin the side panel, the `startActivity()` method is called ([Step 2](#start-add-on-activity))\nby populating the starting state with the user's selected color. After the\nactivity starts, the main stage retrieves the starting state by\n[calling the `getActivityStartingState()` method](https://github.com/googleworkspace/meet/blob/3311b735550b8927c8b7ef2c6d06f768d9fe0476/addons-web-sdk/samples/animation-next-js/src/app/mainstage/page.tsx#L34)\n([Step 3](#get-state)). [Step 4](#share-state) is omitted, as state (the\nselected color) is not shared between participants during the activity in this\nsample add-on. Individual users can, however, change\ntheir own state by selecting a color, which is sent from the side panel frame to\nthe main stage frame using [frame-to-frame messaging](/workspace/meet/add-ons/guides/frame-to-frame-messaging).\n\nConstraints\n-----------\n\n- The URLs specified in the `ActivityStartingState` must belong to the same [origin](/workspace/meet/add-ons/guides/overview#origin) as the origins specified in the [add-on manifest](/workspace/meet/add-ons/guides/deploy-add-on#create-deployment). For more information, see [Add-on security](/workspace/meet/add-ons/guides/add-on-security).\n- The [`sidePanelUrl`](/workspace/meet/add-ons/reference/websdk/addon_sdk.activitystartingstate.sidepanelurl) property, [`mainStageUrl`](/workspace/meet/add-ons/reference/websdk/addon_sdk.activitystartingstate.mainstageurl) property, and [`additionalData`](/workspace/meet/add-ons/reference/websdk/addon_sdk.activitystartingstate.additionaldata) property character lengths must conform to their respective size limits as published in the SDK reference docs.\n\nRelated topics\n--------------\n\n- [Use the activity starting state](/workspace/meet/add-ons/guides/activity-starting-state)\n- [Use a Meet add-on](/workspace/meet/add-ons/guides/use-add-on)\n- [Implement the Co-Doing API](/workspace/meet/add-ons/guides/use-CoDoingAPI)\n- [Add-on security](/workspace/meet/add-ons/guides/add-on-security)"]]