Hi!
I’m starting a screen sharing with audio (startShareScreen() method).
Then I want to turn on the microphone, for this I call:
muteShareAudio() method (with await),
then unmuteAudio() (with await).
Then the ‘user-updated’ events start coming first with the field mute: false ,
but immediately after that comes mute: true.
Thus, I cannot turn on the microphone at first try with the screen sharing with audio.
async function shareAudio(){
await stream.startShareScreen(videoElm);
await stream.muteShareAudio();
await stream.unmuteAudio();
}
If the microphone was unmuted before you started sharing the screen, then after calling the stream.muteShareAudio, the microphone will return to the unmuted state. The last statement await stream.unmuteAudio(); is unnecessary.
And for the sake of modularity, the stream.startShareScreen will be resolved once the shared content is sent, regardless of the process of shared tab audio, so it’s safer to rely on the share-audio-change event to manipulate the sharing audio.
@vic.yang, I probably described the problem incorrectly. The muteShareAudio() method is worked but if you turn on the microphone immediately after this method, then the microphone turns on, and then immediately turns off.
I know what you want to say. Could you move your mute share audio and unmute microphone code into the share-audio-change event callback?
There’s a minor issue with the muteShareAudio method, we have already found it and it will be fixed in the upcoming release. Here is some pseudocode for your reference:
let flag=false;
client.on('share-audio-change', async (payload) => {
if (payload.state === 'on') {
if (!flag) {
await stream.muteShareAudio();
flag = true;
await stream.unmuteAudio();
}
}
});