Skip to main content

Video

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

info

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.

import { SignalWire } from "@signalwire/realtime-api";

const client = await SignalWire({ project: "ProjectID Here", token: "API Token Here" });

const videoClient = client.video;

await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started:", roomSession.displayName);
await roomSession.listen({
onMemberJoined: async (member) => {
console.log("Member joined:", member.name);
},
onMemberLeft: async (member) => {
console.log("Member left:", member.name);
}
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended:", roomSession.displayName);
}
});

Classes