このガイドでは、サンプルをセットアップして実行する方法について説明します。 Google Meet アドオンです。
目標
- サンプルを設定します。
- サンプルを実行します。
前提条件
- Google Meet へのアクセス権を持つ Google Workspace アカウント。
- Google Cloud プロジェクト。
- Node.js と npm インストールされています。
サンプルのセットアップ
作業ディレクトリで、次のコマンドを実行して プロジェクト:
npm init
作業ディレクトリに Express.js をインストールします。
npm install express --save
Meet アドオンウェブ SDK をインストールします。
npm install @googleworkspace/meet-addons --save
作業ディレクトリに
index.js
という名前のファイルを作成し、 コード:const express = require('express'); const path = require('path'); var app = express(); app = require("https-localhost")(); app.use(express.static(path.join(__dirname, '/'))); app.use('/', express.static(__dirname + '/node_modules/@googleworkspace/meet-addons')); app.get('/sidepanel', function(req, res){ res.render(path.join(__dirname, 'sidepanel.html')); }); app.get('/mainstage', function(req, res){ res.render(path.join(__dirname, 'mainstage.html')); }); app.listen(3000);
作業ディレクトリに
mainstage.html
という名前のファイルを作成し、 コード:<html style="width: 100%; height: 100%"> <head> <title>Main Stage Add On</title> <script src="meet.addons.js"></script> </head> <body style="width: 100%; height: 100%; margin: 0; background: white;"> <div style="display: flex; flex-direction: column; height: 100%"> <h1>Main Stage Add-on</h1> <div> <div> <button id="get-collaboration-starting-state"> getCollaborationStartingState </button> </div> <div id="receivedCollaborationStartingState" style="margin-left: 20px; width: 300px; overflow-wrap: anywhere"></div> </div> </div> <script> let mainStageClient; async function init() { const session = await window.meet.addon.createAddonSession({ cloudProjectNumber: "CLOUD_PROJECT_NUMBER", }); console.log("Successfully constructed the add-on session."); const mainStageClient = await session.createMainStageClient(); console.log("Successfully constructed main stage client."); document .getElementById('get-collaboration-starting-state') .addEventListener( 'click', async () => { document.getElementById( 'receivedCollaborationStartingState').textContent = JSON.stringify( await mainStageClient.getCollaborationStartingState()); }); } document.body.onload = () => { init(); }; </script> </body> </html>
作業ディレクトリに
sidepanel.html
という名前のファイルを作成し、 コード:<html style="width: 100%; height: 100%"> <head> <title>Side Panel Add-on</title> <script src="meet.addons.js"></script> </head> <body style="width: 100%; height: 100%; margin: 0"> <div style="display: flex; flex-direction: column; height: 100%"> <h1>Side Panel Add-on</h1> <div> <div> <button id="set-collaboration-starting-state"> setCollaborationStartingState </button> </div> <div> <input type="text" id="sidePanelIframeUrl" style="margin-left: 20px" value="https://localhost:3000/sidepanel.html" /> </div> <div> <input type="text" id="mainStageIframeUrl" style="margin-left: 20px" value="https://localhost:3000/mainstage.html" /> </div> <div> <input type="text" id="additionalData" style="margin-left: 20px" value="additional data" /> </div> </div> </div> <script> let sidePanelClient; async function init() { const session = await window.meet.addon.createAddonSession({ cloudProjectNumber: "CLOUD_PROJECT_NUMBER", }); console.log("Successfully constructed the add-on session."); sidePanelClient = await session.createSidePanelClient(); console.log("Successfully constructed side panel client."); document .getElementById('set-collaboration-starting-state') .addEventListener( 'click', async () => { const sidePanelIframeUrlInputElement = document.getElementById('sidePanelIframeUrl'); const mainStageIframeUrlInputElement = document.getElementById('mainStageIframeUrl'); const additionalDataInputElement = document.getElementById('additionalData'); await sidePanelClient.setCollaborationStartingState({ sidePanelUrl: sidePanelIframeUrlInputElement.value, mainStageUrl: mainStageIframeUrlInputElement.value, additionalData: additionalDataInputElement.value, }); }); } document.body.onload = () => { init(); }; </script> </body> </html>
mainstage.html
ファイルとsidepanel.html
ファイルの両方で次のように置き換えます。CLOUD_PROJECT_NUMBER
: プロジェクトのプロジェクト番号 Google Cloud プロジェクト
作業ディレクトリに https-localhost をインストールします。 パッケージ:
npm install https-localhost --save
作業ディレクトリでサンプルを実行します。
node index.js
ブラウザで
https://localhost:3000/mainstage.html
にアクセスし、https://localhost:3000/sidepanel.html
してウェブページを確認します。
Meet アドオンを作成する
以下の手順に沿って、アドオンのデプロイを設定します。 Meet アドオンを作成するをご覧ください。
サンプルの実行
Meet に移動します。
アクティビティ アイコン をクリックします。
[アドオン] セクションに、
Google Meet Add-ons Quickstart
。これを選択して できます。