Skip to main content

Events

You can subscribe to various events on the local user by calling meeting.self.on(EVENT_NAME).

Room joined

Triggered when the room join event completes and now the meeting is ready to produce and consume media.

meeting.self.on('roomJoined', () => {
console.log(
'User has joined the meeting and ready to produce and consume media'
);
});

Room left

Triggered when the local user leaves the meeting.

meeting.self.on('roomLeft', ({ state }) => {
// state is a string whose values are explained below
if (state === 'left') {
console.log('User has left the meeting');
}
});

Here are all the possible values of the state variable.

EventDescription
leftParticipant has left the room.
kickedParticipant is removed from the meeting.
endedEveryone is removed from the meeting, and the session has ended.
rejectedParticipant's request to join the room is rejected (when you're in a waiting room).

Video update

Triggered when the user starts / stops the video using enableVideo or disableVideo

const videoElem = document.getElementById('my-video');

meeting.self.on('videoUpdate', async ({ videoEnabled, videoTrack }) => {
if (videoEnabled) {
const stream = new MediaStream();
stream.addTrack(videoTrack);
videoElem.srcObject = stream;
videoElem.play();
} else {
videoElem.stop();
}
});

Audio update

Triggered when the user starts / stops the audio using enableAudio or disableAudio

const audioElem = document.getElementById('my-audio');

meeting.self.on('audioUpdate', async ({ audioEnabled, audioTrack }) => {
if (audioEnabled) {
const stream = new MediaStream();
stream.addTrack(audioTrack);
audioElem.srcObject = stream;
audioElem.play();
} else {
audioElem.stop();
}
});

Screenshare update

Triggered when the user starts / stops the screen share using enableScreenShare() or disableScreenShare().

meeting.self.on(
'screenShareUpdate',
async ({ screenShareEnabled, screenShareTracks }) => {
if (screenShareEnabled) {
// Display the screenshare
} else {
// Stop the screenshare
}
}
);

Device update

Subscribe to the deviceUpdate event to handle the changing video, audio and speaker devices

meeting.self.on('deviceUpdate', ({ device }) => {
// handle microphone device change
if (device.kind === 'audioinput') {
console.log('mic change', device);
}
// handle camera device change
if (device.kind === 'videoinput') {
console.log('camera change', device);
}
// handle speaker device change
if (device.kind === 'audiooutput') {
console.log('speaker change', device);
}
});

Network quality score

Subscribe to the mediaScoreUpdate event to monitor network

meeting.self.on('mediaScoreUpdate', ({ kind, isScreenshare, score }) => {
if (kind === 'video') {
console.log(
`Your ${isScreenshare ? 'screenshare' : 'video'} quality score is `,
score
);
}

if (kind === 'audio') {
console.log('Your audio quality score is ', score);
}

if (score < 5) {
console.log('Your media quality is poor');
}
});

Webinar Stage events

In a WEBINAR setup, below events can be used to bring a user on to stage

EventDescription
waitlistedEmitted when the user has been added to the waitlist.
joinStageRequestAcceptedEmitted to all host users, when a host accepts a user's request to join webinar meeting.
joinStageRequestRejectedEmitted to all host users, when a host rejects a user's request to join webinar meeting.
removedFromStageEmitted when the user has been kicked from the webinar meeting.
stageJoinedEmitted when the user has joined the webinar meeting.
stageLeftEmitted when the user has left the webinar meeting.
peerRequestToJoinStageEmitted when a user has requested to join the webinar meeting.
peerRejectedToJoinStageEmitted when the user's request to join the meeting has been rejected.
peerAcceptedToJoinStageEmitted when the user's request to join the meeting has been accepted
peerStoppedPresentingEmitted when a participant stops presenting in the webinar meeting.
peerStartedPresentingEmitted when a participant starts presenting in the webinar meeting.