Manage other participants during an active call session. These methods allow you to mute participants, pause their video, and pin/unpin them in the call layout.
Prerequisites
- An active call session
- Access to the
CallSession instance
- Appropriate permissions (typically host/moderator privileges)
Get CallSession Instance
Participant action methods are called on the CallSession singleton:
val callSession = CallSession.getInstance()
CallSession callSession = CallSession.getInstance();
Mute Participant
Mute a specific participant’s audio. This prevents other participants from hearing them.
val participantId = "participant_uid"
callSession.muteParticipant(participantId)
String participantId = "participant_uid";
callSession.muteParticipant(participantId);
| Parameter | Type | Description |
|---|
participantId | String | The unique identifier of the participant to mute |
When a participant is muted, all participants receive the onParticipantAudioMuted(Participant) callback on their ParticipantEventListener.
Pause Participant Video
Pause a specific participant’s video feed. Other participants will see a placeholder instead of their video.
val participantId = "participant_uid"
callSession.pauseParticipantVideo(participantId)
String participantId = "participant_uid";
callSession.pauseParticipantVideo(participantId);
| Parameter | Type | Description |
|---|
participantId | String | The unique identifier of the participant whose video to pause |
When a participant’s video is paused, all participants receive the onParticipantVideoPaused(Participant) callback on their ParticipantEventListener.
Pin Participant
Pin a participant to keep them prominently displayed in the call layout, regardless of who is speaking.
callSession.pinParticipant()
callSession.pinParticipant();
Pinning is particularly useful in Spotlight layout mode where you want to keep a specific participant in focus.
Unpin Participant
Remove the pin from a participant, returning to the default layout behavior.
callSession.unPinParticipant()
callSession.unPinParticipant();
Listen for Participant Events
Register a ParticipantEventListener to receive callbacks when participant states change:
callSession.addParticipantEventListener(this, object : ParticipantEventListener {
override fun onParticipantJoined(participant: Participant) {
Log.d(TAG, "${participant.name} joined the call")
}
override fun onParticipantLeft(participant: Participant) {
Log.d(TAG, "${participant.name} left the call")
}
override fun onParticipantAudioMuted(participant: Participant) {
Log.d(TAG, "${participant.name} was muted")
}
override fun onParticipantAudioUnmuted(participant: Participant) {
Log.d(TAG, "${participant.name} was unmuted")
}
override fun onParticipantVideoPaused(participant: Participant) {
Log.d(TAG, "${participant.name}'s video was paused")
}
override fun onParticipantVideoResumed(participant: Participant) {
Log.d(TAG, "${participant.name}'s video was resumed")
}
override fun onParticipantListChanged(participants: List<Participant>) {
Log.d(TAG, "Participant list updated: ${participants.size} participants")
// Update your participant list UI
}
override fun onDominantSpeakerChanged(participant: Participant) {
Log.d(TAG, "Dominant speaker: ${participant.name}")
}
// Other callbacks...
override fun onParticipantHandRaised(participant: Participant) {}
override fun onParticipantHandLowered(participant: Participant) {}
override fun onParticipantStartedScreenShare(participant: Participant) {}
override fun onParticipantStoppedScreenShare(participant: Participant) {}
override fun onParticipantStartedRecording(participant: Participant) {}
override fun onParticipantStoppedRecording(participant: Participant) {}
})
callSession.addParticipantEventListener(this, new ParticipantEventListener() {
@Override
public void onParticipantJoined(Participant participant) {
Log.d(TAG, participant.getName() + " joined the call");
}
@Override
public void onParticipantLeft(Participant participant) {
Log.d(TAG, participant.getName() + " left the call");
}
@Override
public void onParticipantAudioMuted(Participant participant) {
Log.d(TAG, participant.getName() + " was muted");
}
@Override
public void onParticipantAudioUnmuted(Participant participant) {
Log.d(TAG, participant.getName() + " was unmuted");
}
@Override
public void onParticipantVideoPaused(Participant participant) {
Log.d(TAG, participant.getName() + "'s video was paused");
}
@Override
public void onParticipantVideoResumed(Participant participant) {
Log.d(TAG, participant.getName() + "'s video was resumed");
}
@Override
public void onParticipantListChanged(List<Participant> participants) {
Log.d(TAG, "Participant list updated: " + participants.size() + " participants");
// Update your participant list UI
}
@Override
public void onDominantSpeakerChanged(Participant participant) {
Log.d(TAG, "Dominant speaker: " + participant.getName());
}
// Other callbacks...
@Override
public void onParticipantHandRaised(Participant participant) {}
@Override
public void onParticipantHandLowered(Participant participant) {}
@Override
public void onParticipantStartedScreenShare(Participant participant) {}
@Override
public void onParticipantStoppedScreenShare(Participant participant) {}
@Override
public void onParticipantStartedRecording(Participant participant) {}
@Override
public void onParticipantStoppedRecording(Participant participant) {}
});
Participant Object
The Participant object contains information about a call participant:
| Property | Type | Description |
|---|
uid | String | Unique identifier of the participant |
name | String | Display name of the participant |
avatar | String | URL of the participant’s avatar image |
isAudioMuted | Boolean | Whether the participant’s audio is muted |
isVideoPaused | Boolean | Whether the participant’s video is paused |
Control the visibility of the participant list button in the call UI:
val sessionSettings = CometChatCalls.SessionSettingsBuilder()
.hideParticipantListButton(false) // Show the participant list button
.build()
SessionSettings sessionSettings = new CometChatCalls.SessionSettingsBuilder()
.hideParticipantListButton(false) // Show the participant list button
.build();
Listen for when users tap the participant list button:
callSession.addButtonClickListener(this, object : ButtonClickListener {
override fun onParticipantListButtonClicked() {
Log.d(TAG, "Participant list button clicked")
// Show custom participant list UI if needed
}
// Other ButtonClickListener callbacks...
override fun onLeaveSessionButtonClicked() {}
override fun onRaiseHandButtonClicked() {}
override fun onShareInviteButtonClicked() {}
override fun onChangeLayoutButtonClicked() {}
override fun onToggleAudioButtonClicked() {}
override fun onToggleVideoButtonClicked() {}
override fun onSwitchCameraButtonClicked() {}
override fun onChatButtonClicked() {}
override fun onRecordingToggleButtonClicked() {}
})
callSession.addButtonClickListener(this, new ButtonClickListener() {
@Override
public void onParticipantListButtonClicked() {
Log.d(TAG, "Participant list button clicked");
// Show custom participant list UI if needed
}
// Other ButtonClickListener callbacks...
@Override
public void onLeaveSessionButtonClicked() {}
@Override
public void onRaiseHandButtonClicked() {}
@Override
public void onShareInviteButtonClicked() {}
@Override
public void onChangeLayoutButtonClicked() {}
@Override
public void onToggleAudioButtonClicked() {}
@Override
public void onToggleVideoButtonClicked() {}
@Override
public void onSwitchCameraButtonClicked() {}
@Override
public void onChatButtonClicked() {}
@Override
public void onRecordingToggleButtonClicked() {}
});
Next Steps