Remove and add microphone at beta5 version

两盒软妹~` 提交于 2020-01-05 07:30:32

问题


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

  • When user clicks first time on the button, I need remove his microphone.
  • When user clicks second time on the button, I need restore his microphone.

Beta4 version had two methods: addMicrophone() and removeMicrophone(): https://media.twiliocdn.com/sdk/js/video/releases/1.0.0-beta4/docs/LocalMedia.html

How can I remove and add microphone at beta5 version ?


回答1:


Twilio developer evangelist here.

First up, Video is released as v1 now, so I would change from beta5 to the v1 code.

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();
}).

There's more detail in the documentation.



来源:https://stackoverflow.com/questions/44057718/remove-and-add-microphone-at-beta5-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!