arctos Web-SDK For developsarctos Web-SDK For develops
  • English
  • 繁體中文
  • English
  • 繁體中文
  • Guide

    • get-started
  • overview
  • Spec
  • installization
  • features

    • initial_setting
    • camera
    • microphone
    • speaker
    • share_screen
    • paint_board
    • share_message
    • switch_template
      • Prerequisites
      • Step 1: Initialize Arctos Instance
      • Step 2: Implement Template Switching
        • Template Switching with Synchronization
      • Step 3: Available Templates
        • Special Layout Features
    • video_filters

Switch Template

This guide demonstrates how to dynamically switch meeting room layout templates in an Arctos meeting room. You can change between different predefined layouts and control synchronization behavior.

Prerequisites

Before implementing template switching, ensure you have:

  • Arctos SDK properly loaded
  • Meeting room initialized
  • Appropriate user permissions

Step 1: Initialize Arctos Instance

First initialize an Arctos Instance.

// wait for arctos-widget.js to load
window.addEventListener('ArctosLoad', async function (e) {
    arctosSdkInstance = new Arctos({
      endpointUrl: ENDPOINTURL,
      endpointKey: ENDPOINTKEY,
    });

    // Be careful !!!, the following code is for testing only. You should store the license key in your server side.
    const authCode = await getAuthCode();

    // Retrieve the user token.
    const accessToken = await getAuthToken(authCode);

    // 初始化連線
    await arctosSdkInstance.initSession({
      accessToken: accessToken,
      sessionId: TASKNUM,
    });

    // 初始化會議室
    await arctosSdkInstance.initMeetingRoom({
      isDebug: false,
      recordingAutoStart: false,
      showPrejoin: true,
      showToolbar: true,
    });
});

Step 2: Implement Template Switching

Template Switching with Synchronization

Control whether template changes are synchronized across all participants:

let isSynchronous = false;

// Toggle synchronization mode
switchSynchronous = async function () {
    isSynchronous = !isSynchronous;
    
    // Update UI to reflect current state
    let target = document.querySelector('.syncBtn');
    target.classList.toggle('active', isSynchronous);
};

// Switch template with synchronization control
switchTemplateChange = async function () {
    let str = document.querySelector('#switch-camera-resolution').value;
    arctosSdkInstance.$meetingRoom.setTemplate(str, isSynchronous);
};

Step 3: Available Templates

The following templates are available by default:

Template NameDescriptionSpecial Features
defaultBasic layout templateStandard participant arrangement
template-1Grid layout with equal participant windowsBalanced view for all participants
template-2Speaker focus layout with thumbnailsEmphasizes active speaker
template-3Presentation layout with shared content focusOptimized for content sharing
template-4Gallery view with multiple participantsMulti-participant display
template-5Advanced layout templateEnhanced viewing options
share-1content sharing layoutBasic screen sharing mode
share-2content sharing layout4-participant grid with sharing (grid-layout-4p)
share-3content sharing layout8-participant grid with sharing (grid-layout-8p)
canvas-1Canvas-based layoutInteractive whiteboard support

Special Layout Features

  • share-2 and share-3 templates include a "其他參與者" (Other Participants) button when there are hidden participants
  • Grid layouts: share-2 uses 4-participant grid, share-3 uses 8-participant grid
  • Participant management: Templates automatically handle participant visibility and overflow

The following url is a sample code for template switching.

Sample Code

Prev
share_message
Next
video_filters