Remove Participant - Android
When hosting a live stream, it's essential for the host to have the capability to remove a participant from the live stream. This can be useful in various scenarios where a participant is causing disturbance, behaving inappropriately, or is not following the guidelines. This guide focuses on this very aspect of removing a participant from the live stream.
VideoSDK provides three ways to do so:
1. Using SDK
remove()
Call remove() on a Participant to remove them from the live stream.
remove() is a suspend function, so call it from a coroutine. Whether your token may remove participants is decided by the server: if it refuses, remove() throws a VideoSDKException carrying the server's reason.
btnRemoveParticipant!!.setOnClickListener { _: View? ->
val remoteParticipantId = "<participant-id>"
// Get specific participant instance
val participant = room!!.participants[remoteParticipantId] ?: return@setOnClickListener
lifecycleScope.launch {
try {
// Remove participant from active session
// This will emit an event called "onParticipantLeft" for that particular participant
participant.remove()
} catch (e: VideoSDKException) {
Log.d("VideoSDK", "remove failed: ${e.code} ${e.message}")
}
}
}
Events associated with remove()
The following callbacks are received when a participant is removed from the room.
-
The removed participant receives
onRoomLeftwith the reasonLeaveReason.REMOVE_PEER. -
All other remote participants receive
onParticipantLeftwith the removedParticipantand aLeaveReason. Don't rely on that reason beingLeaveReason.REMOVE_PEER.
2. Using VideoSDK Dashboard
- For removing a participant using the VideoSDK Dashboard, navigate to the session page on VideoSDK Dashboard. Select the specific session, and from the list of participants, choose the participant you wish to remove. Utilize the provided options to remove the selected participant from the session.
3. Using Rest API
- You can also remove a particular participant from the live stream using the REST API.
- To employ this method, you need the
sessionIdof the live stream and theparticipantIdof the individual you intend to remove.
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

