I made a lot of searches, and tried many things. Let's take the same scenario from this question.
Bob, Alice, and Jane are in a conference. I want Bob (the hoster of the room) to be able to mute Alice so sounds from Alice will not come through the room, but Alice still hear sounds from all other participants (Bob & Jane)
Imagine the scenario when you are in conference, and someone disturbs the Live. So I want the hoster to be able to mute or remove the audio track of that person.
So far, I can mute the audio tracks for the local participant with:
$(document).on("click",'.mute-audio',function(){
if(room){
let microEnabled = true;
microEnabled = !microEnabled;
room.localParticipant.audioTracks.forEach(function(audioTrack) {
audioTrack.enable(microEnabled);
});
}
});
We simply iterate through audioTracks of the local participant, and if I want to do so for a specific User, I just need to know his identity
and I am good to go:
$(document).on("click",'.mute-user',function(){
var identity = $(this).data('identity'); // i.e the unique ID USER2323
if(room){
var user_to_mute;
room.participants.audioTracks.forEach(function(participant) {
audioTrack.enable(microEnabled);
user_to_mute = participant;
// We retrieve the target
return;
});
let m_Enabled = true;
m_Enabled = !m_Enabled;
if(user_to_mute){
user_to_mute.audioTracks.forEach(function(audioTrack) {
audioTrack.enable(m_Enabled);
// the error is here I think
return;
});
}
}
});
But it doesn't work, when I try I got this error from the browser
TypeError: audioTrack.enable is not a function