【发布时间】:2018-07-31 23:41:51
【问题描述】:
我进行了很多搜索,并尝试了很多东西。让我们以 this question 的相同场景为例。
Bob、Alice 和 Jane 正在开会。我希望 Bob(房间的主人)能够将 Alice 静音,这样 Alice 的声音就不会穿过房间,但 Alice strong>Alice 仍能听到所有其他参与者的声音(Bob 和 Jane)
想象一下,当您在开会时,有人打扰了现场直播。所以我希望主持人能够静音或删除那个人的音轨。
到目前为止,我可以通过以下方式将本地参与者的音轨静音:
$(document).on("click",'.mute-audio',function(){
if(room){
let microEnabled = true;
microEnabled = !microEnabled;
room.localParticipant.audioTracks.forEach(function(audioTrack) {
audioTrack.enable(microEnabled);
});
}
});
我们只是遍历本地参与者的音频轨道,如果我想为特定用户这样做,我只需要知道他的identity 就可以了:
$(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;
});
}
}
});
但它不起作用,当我尝试时,我从浏览器收到此错误
TypeError: audioTrack.enable is not a function
【问题讨论】:
标签: javascript twilio twilio-api twilio-functions