setMemberPosition

View as Markdown

setMemberPosition

  • setMemberPosition(params): Promise<void>

Assigns a position in the layout to the specified member.

Parameters

params
objectRequired

Object containing the parameters of the method.

memberId
string

ID of the member to affect.

position
VideoPositionRequired

Position to assign in the layout.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then set the roomlayout to "6x6". When a second member joins the room, we set the position of that member to "off-canvas". 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: async (roomsession) => {
12
13 // Set the layout of the room
14 roomsession.setLayout({
15 name: "6x6",
16 });
17
18 // listens for when a member joins the room
19 await roomsession.listen({
20
21 onMemberJoined: async (member) => {
22 console.log("Member joined", member.name);
23 // Set position for the member
24 roomsession.setMemberPosition({
25 memberId: member.id,
26 position: "off-canvas"
27 });
28 },
29 onMemberUpdated: async (member) => {
30 console.log(`Updated ${member.name} position`);
31 },
32
33 onRoomUpdated: async (room) => {
34 console.log(`Room updated to ${room.layoutName}`);
35 },
36 });
37 }
38})