Channel Participants

Channel Participants

A participant object represents a user that is connected to a given channel. You can get the list of participants from the VideoChannel object. You will also get a list of participants with the onParticipantsChanged event.

Event

Description

onParticipantsChanged

When you join a channel you will there will be an event that gives you a list of the current channel participants. While in a given channel a similar event is fired each time a participant enters or leaves the channel. You will also see this event when a participant publishes/unpublishes or modifies their stream.

Example onParticipantsChanged Event Payload

{
  detail: {
    // currentParticipantId: This is the connectionId of the current user
    currentParticipantId: "871f35b5-479e-4b99-acba-71ab6fe50768",
    
    // Current Channel
    channel: AudioChannel{...},
    
    // List of participants in the channel
    participants: [Participant, Participant]      
  }
}

Rendering Participants

function handleParticipantListChange(event) {
  const participants = event.detail.participants;
  let participantList = participants.map(function (participant) {
    return '<li>' + participant.name + ' (' + participant.id+ ') '+ (participant.isPublishingStream ? ' (published)' : '') + '</li>';
  }).join('');
  
  document.getElementById('channel-participants').innerHTML = `<ul>${participantList}</ul>`;
}

Last updated