Skip to main content

The participant object

The participant object consists of all the information related to a particular participant. For instance, it contains a partcipants video/audio/screenshare stream, and the participant's name. It also contains state variables that indicate whether a participant's camera is on or off, and whether they are muted or unmuted. Head over to DyteParticipant for a detailed reference.

The participant object has the following properties.

  • id: The participantId of the participant (aka peerId).
  • userId: The userId of the participant.
  • name: The participant's name.
  • picture: The participant's picture (if any).
  • clientSpecificId: An arbitrary ID that can be set to identify the participant.
  • device: Information about the device used by the participant.
  • videoTrack: The video track of the participant.
  • audioTrack: The audio track of the participant.
  • screenShareTracks: The video and audio (if any) track of the participant's screen share stream.
  • videoEnabled: Set to true if the participant's camera is on.
  • audioEnabled: Set to true if the participant is unmuted.
  • screenShareEnabled: Set to true if the participant is sharing their screen.
  • supportsRemoteControl: Set to true if the participant is using an SDK that supports remote control.
  • isPinned: Set to true if the participant is pinned.

The participant object is an event emitter, so you can set listeners on this object for events such as video and audio updates. For instance, to fire a callback when a participant toggles their mic, you can subscribe to the following events.

meeting.participants.joined
.get(participantId)
.on('audioUpdate', ({ audioEnabled, audioTrack }) => {
// This will only be fired on mic toggles for the participant with ID `participantId`
console.log(
'The participant with id',
participantId,
'has toggled their mic to',
audioEnabled
);
});

The events emitted by all participant objects are also re-emitted by all the maps in meeting.participants. Therefore, you can add a listener to meeting.participants.joined for the audioUpdate event. For instance, the same code above can be re-implemented as follows.

meeting.participants.joined.on(
'audioUpdate',
(participant, { audioEnabled, audioTrack }) => {
// This will be fired on mic toggles for all participants in the meeting
console.log(
'The participant with id',
participantId,
'has toggled their mic to',
audioEnabled
);
}
);

Read more about the participant events in the events section in the API reference.

Host controls methods

If you (the local user) have the relevant permissions in the meeting, you can disable a participant's video/audio streams, or even remove them from the meeting.

const participant = meeting.participants.joined.get(participantId);

// To disable a participant's video stream
participant.disableVideo();

// To disable a participant's audio stream
participant.disableAudio();

// To kick a participant from the meeting
participant.kick();

You can also pin or unpin a participant in the meeting. All "pinned" participants are added to the meeting.participants.pinned map.

const participant = meeting.participants.joined.get(participantId);

// Pin a participant to the meeting.
await participant.pin();

// Unpin a participant in the meeting.
await participant.unpin();