audioUnmute

View as Markdown

audioUnmute

  • audioUnmute(params): Promise<void>

Unmutes the microphone of a given member if it had been previously muted.

Parameters

params
object

Object containing the parameters of the method.

memberId
string

ID of the member to unmute.

Returns

Promise<void>

Example

In this example, we mute the audio of a member as soon as they join the room. After 5 seconds, we unmute the member’s audio. 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 the 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 console.log("Room started", roomSession.displayName);
13 await roomSession.listen({
14 // Listen for when a member joins the room
15 onMemberJoined: async (member) => {
16 // Mute member's audio
17 console.log(`Muting ${member.id}'s audio`);
18 await roomSession.audioMute({ memberId: member.id });
19 // Unmute member's audio after 5 seconds
20 setTimeout(() => {
21 console.log(`Unmuting ${member.id}'s audio`);
22 roomSession.audioUnmute({ memberId: member.id });
23 }, 5000);
24 }
25 });
26 },
27 onRoomEnded: async (roomSession) => {
28 console.log("Room ended", roomSession.displayName);
29 }
30});