@Payal Tiwari I want to be clear that there is not an officially supported method to block certain users incoming or outgoing audio.
There might be a few workarounds but keep in mind, I have put these together more so in theory and they may not work for your setup or future updates could break it.
Mute Specific Remote Participant for Others:
While ACS does not natively support muting a participant's audio for specific others directly, you can handle this on the receiving end.
const callAgent = await callClient.createCallAgent(tokenCredential);
const call = await callAgent.join({ groupId: '<group-id>' }, { videoOptions: { localVideoStreams: [] } });
call.on('remoteParticipantsUpdated', (e) => {
e.added.forEach(remoteParticipant => {
remoteParticipant.on('videoStreamsUpdated', (streamEvent) => {
streamEvent.added.forEach(remoteVideoStream => {
const renderer = new VideoStreamRenderer(remoteVideoStream);
const view = await renderer.createView();
document.getElementById('remoteVideoContainer').appendChild(view.target);
});
});
// Listen to audio streams
remoteParticipant.on('stateChanged', () => {
if (remoteParticipant.state === 'Connected') {
remoteParticipant.audioStreams.forEach(remoteAudioStream => {
// Disable the audio stream for other participants, keeping it active only for the host
if (remoteParticipant.identifier !== hostIdentifier) {
remoteAudioStream.stop();
}
});
}
});
});
});
For iOS, you’ll have to manage the audio streams similarly by controlling which streams are played back on each participant’s device. Here’s a conceptual approach:
- Configure Audio for Participants: When a participant connects, you can decide which remote audio streams to subscribe to. If a participant should not hear another participant, you do not subscribe to their audio stream.
- Host Audio Management: The host subscribes to all audio streams to hear everyone, while each participant only subscribes to the host's audio stream.
call.remoteParticipants.forEach { remoteParticipant in remoteParticipant.delegate = self } // Delegate method to handle remote participant's audio stream state func remoteParticipant(_ remoteParticipant: RemoteParticipant, didUpdate audioStreams: [RemoteAudioStream]) { for audioStream in audioStreams { if remoteParticipant.identifier != hostIdentifier { // Stop or do not subscribe to the audio stream audioStream.stop() } } }