问题
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