setLayout

View as Markdown

setLayout

  • setLayout(params): Promise<void>

Sets a layout for the room. You can obtain a list of available layouts with getLayouts.

Parameters

params
objectRequired

Object containing the parameters of the method.

name
stringRequired

Name of the layout.

positions
VideoPositions

Positions to assign as soon as the new layout is set. See VideoPositions.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then set the layout for that room to "6x6". This example assumes that there is a RoomSession already active and that members are joining the room.

1import { SignalWire } from "@signalwire/realtime-api";
2
3// Initialize the SignalWire client
4const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })
5
6// Access video client from the main client
7const videoClient = client.video;
8
9// Setup listener for when a room starts
10await videoClient.listen({
11 onRoomStarted: (roomsession) => {
12 console.log("Room started", roomsession.displayName);
13 // Set the 6x6 layout
14 roomsession.setLayout({
15 name: "6x6",
16 positions: {
17 self: 'auto'
18 }
19 });
20 roomsession.listen({
21 onRoomUpdated: (roomsession) => {
22 console.log("Room layout updated", roomsession.layoutName);
23 },
24 })
25 }
26});