साइड पैनल और मुख्य पेज बनाना

इस पेज पर, Meet के वेब ऐड-ऑन के साइड पैनल और मुख्य स्टेज वाले पेज बनाने का तरीका बताया गया है.

Meet ऐड-ऑन SDK टूल का मुख्य स्टेज और साइड पैनल.
Meet के वेब ऐड-ऑन का मुख्य स्टेज और साइड पैनल.

Google Meet ऐड-ऑन SDK टूल, gstatic के JavaScript बंडल के तौर पर उपलब्ध है. यह डोमेन स्टैटिक कॉन्टेंट उपलब्ध कराता है.

Meet ऐड-ऑन SDK टूल का इस्तेमाल करने के लिए, अपने ऐप्लिकेशन में यह स्क्रिप्ट टैग जोड़ें:

<script src="https://www.gstatic.com/meetjs/addons/0.7.0/meet.addons.js"></script>

Meet ऐड-ऑन SDK टूल की सुविधा, window.meet.addon में उपलब्ध है. रेफ़रंस दस्तावेज़ देखने के लिए, संसाधन की खास जानकारी देखें.

बताएं कि ऐड-ऑन लोड हो गया है

ऐड-ऑन के लोड होने के दौरान, Meet लोड होने की स्क्रीन दिखाता है. ऐड-ऑन सेशन शुरू होने के बाद, Meet इसे ऐड-ऑन से मिलने वाले सिग्नल के तौर पर देखता है और यह कि लोड होने की प्रोसेस पूरी हो गई है. उपयोगकर्ता तीसरे पक्ष के कॉन्टेंट के साथ इंटरैक्ट कर सकता है.

साइड-पैनल पेज बनाना

साइड पैनल में इंस्टॉल किए गए ऐसे ऐड-ऑन दिखते हैं जिन्हें चुनकर इस्तेमाल किया जा सकता है. ऐड-ऑन चुनने के बाद, iframe उस साइड पैनल का यूआरएल लोड करता है जिसे आपने ऐड-ऑन मेनिफ़ेस्ट में तय किया है. साइड पैनल में Meet ऐड-ऑन SDK टूल की सुविधा ऐक्सेस करने के लिए, आपको sidePanelClient को इंस्टैंशिएट करना होगा.

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

यहां एक कोड स्निपेट दिया गया है, जिसमें साथ मिलकर काम करने का तरीका बताया गया है:

<html style="width: 100%; height: 100%">

<head>
    <title>Side Panel Add-on</title>
<script src="https://www.gstatic.com/meetjs/addons/0.7.0/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="start-collaboration">
                    startCollaboration
                </button>
            </div>
            <div>
                <input type="text" id="sidePanelIframeUrl" style="margin-left: 20px"
                    value="https://your_side_panel_iframe.url" />
            </div>
            <div>
                <input type="text" id="mainStageIframeUrl" style="margin-left: 20px"
                    value="https://your_main_stage_iframe.url" />
            </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('start-collaboration')
                .addEventListener(
                    'click', async () => {
                        const sidePanelIframeUrlInputElement =
                            document.getElementById('sidePanelIframeUrl');
                        const mainStageIframeUrlInputElement =
                            document.getElementById('mainStageIframeUrl');
                        const additionalDataInputElement =
                            document.getElementById('additionalData');
                        await sidePanelClient.start-collaboration({
                            sidePanelUrl: sidePanelIframeUrlInputElement.value,
                            mainStageUrl: mainStageIframeUrlInputElement.value,
                            additionalData: additionalDataInputElement.value,
                        });
                    });
        }
        document.body.onload = () => {
            init();
        };
    </script>
</body>

</html>

मुख्य स्टेज वाला पेज बनाएं

मुख्य स्टेज, वह मुख्य फ़ोकस होता है जहां ज़्यादा काम करने की ज़रूरत पड़ने पर ऐड-ऑन दिखाया जा सकता है. साथ मिलकर काम करने की सुविधा शुरू होने के बाद, मुख्य स्टेज खुल जाता है. मुख्य चरण में Meet ऐड-ऑन SDK टूल की सुविधाओं को ऐक्सेस करने के लिए, क्लाइंट ऑब्जेक्ट का इस्तेमाल किया जा सकता है MeetMainStageClient :

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

यहां एक कोड स्निपेट दिया गया है, जो एक मुख्य चरण का उदाहरण दिखाता है. इसमें getCollaborationStartingState शामिल है:

<html style="width: 100%; height: 100%">

<head>
    <title>Main Stage Add On</title>
    <script src="https://www.gstatic.com/meetjs/addons/0.7.0/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>