使其他用户对特定用户静音
可以使用本地静音使其他用户对特定用户静音。VivoxParticipant.MutePlayerLocally
函数可阻止用户听到已静音用户,但是频道中的其他用户可继续听到已静音用户。VivoxParticipant.UnmutePlayerLocally
可用于让用户再次听到已静音用户。
例如,频道中有 Cynthia、Fernando 和 Wang 三人。Fernando 不希望听到 Wang 的音频。使用本地静音可以允许 Fernando 停止听到 Wang 的音频。但是,Cynthia 可继续听到 Wang,而 Wang 可继续听到 Cynthia 和 Fernando。
因为是 VivoxParticipant 函数,所以最好采用一些方法来处理每个 VivoxParticipant 的单独 UI 表示,从而令所有人都拥有各自的静音按钮(如 Chat Channel Sample 和参与者管理页面所示)。
或者,以下示例展示了使用 VivoxServices.Instance.ActiveChannels
字典在特定频道中查找特定参与者并对其进行静音/取消静音(使用参与者的 PlayerId 和频道的 ChannelName):
void MutePlayerLocally(string PlayerId, string ChannelName)
{
VivoxService.Instance.ActiveChannels[ChannelName].Where(participant => participant.PlayerId == PlayerId).First().MutePlayerLocally();
}
void UnmutePlayerLocally(string PlayerId, string ChannelName)
{
VivoxService.Instance.ActiveChannels[ChannelName].Where(participant => participant.PlayerId == PlayerId).First().UnmutePlayerLocally();
}
注意:要更新 UI 元素以指示某个用户已静音的用户,则需要等到从 Vivox SDK 收到事件,以确认其他用户已静音。您可以在 Chat Channel Sample 和参与者管理页面中找到处理此事件并将其实现到 UI 中的示例。