Video

View as Markdown

Access the Video API Consumer. You can instantiate a Video.Client to subscribe to Video events.

For the full list of events that a Video.Client can subscribe to, refer to Video Events.

Example

The following example logs whenever a room session is started or when a user joins it. A RoomSession can be created through the Browser SDK, through the Create a Room REST API, or through the SignalWire Dashboard, utilizing a Personal Video Conference (PVC).

When a RoomSession is created, the onRoomStarted event is triggered. We can then subscribe to the RoomSession events, such as onMemberJoined and onMemberLeft, using the listen method.

1import { SignalWire } from "@signalwire/realtime-api";
2
3const client = await SignalWire({ project: "ProjectID Here", token: "API Token Here" });
4
5const videoClient = client.video;
6
7await videoClient.listen({
8 onRoomStarted: async (roomSession) => {
9 console.log("Room started:", roomSession.displayName);
10 await roomSession.listen({
11 onMemberJoined: async (member) => {
12 console.log("Member joined:", member.name);
13 },
14 onMemberLeft: async (member) => {
15 console.log("Member left:", member.name);
16 }
17 });
18 },
19 onRoomEnded: async (roomSession) => {
20 console.log("Room ended:", roomSession.displayName);
21 }
22});

Classes