本文介绍了在 beta5 版本中删除和添加麦克风的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用新的 beta5 版本的 Twilio 创建视频聊天:https://media.twiliocdn.com/sdk/js/video/releases/1.0.0-beta5/docs/#toc5__anchor

I use new beta5 version of Twilio to create video chat:https://media.twiliocdn.com/sdk/js/video/releases/1.0.0-beta5/docs/#toc5__anchor

  • 当用户第一次点击按钮时,我需要删除他的麦克风.
  • 当用户第二次点击按钮时,我需要恢复他的麦克风.

Beta4 版本有两种方法:addMicrophone()removeMicrophone()>:https://media.twiliocdn.com/sdk/js/video/releases/1.0.0-beta4/docs/LocalMedia.html

如何在 beta5 版本中删除和添加麦克风?

How can I remove and add microphone at beta5 version ?

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

首先,视频现已发布为 v1,所以我将从 beta5 更改为 v1 代码.

然后,要将本地音频静音,您可以在房间环境中进行.您需要为本地参与者收集媒体轨道,然后您可以禁用轨道.removeMicrophone 方法是一种快捷方式,但我相信它已被删除,因为可能有多个麦克风正在使用并且处理轨道本身更灵活.

Then, to mute your local audio, you can do so in the context of a room. You need to gather the media tracks for your local participant and you can then disable a track. The removeMicrophone method was a shortcut to this, however I believe it has been removed as there could be multiple microphones in use and dealing with tracks themselves is more flexible.

这是获取所有本地曲目并禁用它们的方法.您可能需要做更多工作才能仅禁用音轨.

This is how you would get all local tracks and disable them. You might have to do a bit more work to only disable audio tracks.

var localMedia = room.localParticipant.media; 
localMedia.tracks.forEach(function (track) {
  track.disable();
}).

文档中有更多详细信息.

这篇关于在 beta5 版本中删除和添加麦克风的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 18:33