Skip to main content
Version: 3.x.x

Participant Events - Flutter

VideoSDK provides various events that can be utilized to gather information about the participants in the meeting.

Here are the events specifically related to the participant:

Events.participantJoined

  • This event is triggered when someone joins the meeting, returning the Participant object as parameter.
  • It can be subscribed to using the Room object.

Events.participantLeft

  • This event is triggered when someone leaves the meeting, along with the participantId and Reason. You can refer to the reason details here.
  • It can be subscribed to using the Room object.
  • When Events.participantLeft is triggered, a reason object is also provided.
  • The table below outlines the possible reason codes and their descriptions:
TypeCodeMessage
WEBSOCKET_DISCONNECTED1001Socket disconnected.
REMOVE_PEER1002Participant was removed from the meeting.
REMOVE_PEER_VIEWER_MODE_CHANGED1003Participant removed because viewer mode was changed.
REMOVE_PEER_MEDIA_RELAY_STOP1004Your organization has reached the maximum number of speakers allowed.
SWITCH_ROOM1005Participant switched to a different room.
ROOM_CLOSE1006The meeting has been closed.
UNKNOWN1007Participant disconnected due to an unknown reason.
REMOVE_ALL1008Remove All from the meeting.
MEETING_END_API1009Meeting Ended.

Events.cameraRequested

  • This event is triggered for participant B, when another participant, A requests to enable their webcam.
  • Upon accepting the request, participant B's webcam will be enabled.
  • It can be subscribed to using the Room object.

Events.micRequested

  • This event is triggered for participant B, when another participant, A requests to enable their mic.
  • Upon accepting the request, participant B's mic will be enabled.
  • It can be subscribed to using the Room object.

Example

Here is an example demonstrating the usage of all the events mentioned on this page.

import 'package:flutter/material.dart';
import 'package:videosdk/videosdk.dart';

class MeetingScreen extends StatefulWidget {
//Existing configuration
}

class _MeetingScreenState extends State<MeetingScreen> {
late Room _room;

@override
void initState() {
//Existing configuration

setupRoomEventListener();
}

@override
Widget build(BuildContext context) {
return YourMeetingWidget();
}

void setupRoomEventListener() {
_room.on(Events.participantJoined, (Participant participant) {
// New Participant joined the room
});

_room.on(Events.participantLeft, (String participantId , LeaveReason reason) {
// Participant left the room
});

_room.on(Events.cameraRequested, (data) {
String? participantId = data["participantId"];

Function accept = data["accept"];
Function reject = data["deny"];

// participantId, will be the id of participant who requested to enable camera

// if the request is accepted
accept();

// if the request is rejected
reject();
});

_room.on(Events.micRequested, (data) {
String participantId = data["participantId"];

Function accept = data["accept"];
Function reject = data["reject"];

// participantId, will be the id of participant who requested to enable camera

// if the request is accepted
accept();

// if the request is rejected
reject();
});
}
}

API Reference

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord