使用 Meet 插件开展协作
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
会议参与者可以协作处理 Google Meet 插件活动。协作活动开始后,会议中的所有参与者都会收到活动正在进行的通知。
此通知会根据插件的可用性和安装状态进行调整:
当用户加入活动时,他们将加载包含您的插件内容的自己的 iframe。您可以自定义新加入者应在主舞台还是侧边栏中打开协作活动。
开始活动
通过调用 startActivity()
方法(使用 ActivityStartingState
接口)来启动 activity。
第 1 步(可选):插件设置 activity 启动状态
ActivityStartingState
包含有关插件初始状态的信息,当参与者接受加入活动的邀请时,系统会使用该信息。
插件可以在活动开始前或活动期间随时通过调用 setActivityStartingState()
方法来设置或更新 ActivityStartingState
。如果 ActivityStartingState
仅在对 startActivity()
的调用中设置,则可以省略对 setActivityStartingState()
的调用。
第 2 步:插件开始活动
当插件在 MeetSidePanelClient
上调用 startActivity()
方法时,activity 开始运行。
startActivity()
方法接受 ActivityStartingState
对象作为参数,因此可以调用 startActivity()
,而不是调用 setActivityStartingState()
。
用户完成内容选择并准备好开始 activity 后,请在插件中调用 startActivity()
方法,如下所示:
sidePanelClient.startActivity({
mainStageUrl: "https://app.example.com/mainstage",
additionalData: JSON.stringify({
// State to send to participants.
})
});
调用 startActivity()
方法时,Meet 会执行以下操作:
第 3 步:获取 activity 的初始状态
当用户加入活动时,他们会将插件加载到主舞台或侧边栏中,具体取决于 ActivityStartingState
。
借助 additionalData
属性,您可以与加入 activity 的用户分享初始数据(也称为状态)。初始化 MainStageClient
或 SidePanelClient
后,您可以调用 getActivityStartingState()
方法来检索 additionalData
属性。
const startingState = client.getActivityStartingState();
const additionalData = JSON.parse(startingState.additionalData);
第 4 步(可选):在 activity 中共享插件状态
您还可以在活动进行期间在用户之间共享状态。您可以通过以下两种方式共享状态:
示例:GitHub 上的动画插件
GitHub 上的“动画”示例插件包含插件中的协作。本指南中的第 1 步未包含在试阅内容中。相反,当插件启动器点击侧边栏中的“Start the Animation”按钮时,系统会通过填充用户选择的颜色来填充初始状态,从而调用 startActivity()
方法(第 2 步)。在 activity 启动后,主舞台会通过调用 getActivityStartingState()
方法来检索初始状态(第 3 步)。此示例插件中,activity 期间参与者之间不共享状态(所选颜色),因此省略了第 4 步。不过,个别用户可以通过选择颜色来更改自己的状态,该颜色会使用帧到帧消息传递从侧边栏框架发送到主舞台框架。
限制条件
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):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)"]]