文档

支持

Vivox Unity SDK

Vivox Unity SDK

使其他用户对特定用户静音

How to mute other users for a specific player.
阅读时间1 分钟最后更新于 13 天前

可以使用本地静音使其他用户对特定用户静音。
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();}