# muteShareAudio() don't work

**URL:** <https://devforum.zoom.us/t/muteshareaudio-dont-work/74876>\
**Category:** Web\
**Created:** [August 25, 2022, 11:46am UTC](https://devforum.zoom.us/t/muteshareaudio-dont-work/74876 "2022-08-25T11:46:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![efron.vit](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/efron.vit/32/33711_2.png) [@efron.vit](https://devforum.zoom.us/u/efron.vit)\
**Post date:** [August 25, 2022, 11:46am UTC](https://devforum.zoom.us/t/muteshareaudio-dont-work/74876/1 "2022-08-25T11:46:39Z")

</div>

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.

console.log:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/7/2/729240b5aa711f419e987a01a0633aef0a4a114e.jpeg)

p.s.  
speakerOnly: false  
v 1.4.0

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [August 26, 2022, 6:56am UTC](https://devforum.zoom.us/t/muteshareaudio-dont-work/74876/2 "2022-08-26T06:56:34Z")

</div>

Hey @efron.vit

Did you operate like the following pseudocode:

```javascript
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.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![efron.vit](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/efron.vit/32/33711_2.png) [@efron.vit](https://devforum.zoom.us/u/efron.vit)\
**Post date:** [August 26, 2022, 7:19am UTC](https://devforum.zoom.us/t/muteshareaudio-dont-work/74876/3 "2022-08-26T07:19:17Z")

</div>

@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.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/5/5/55b460cbb83d4a55b12231d60e1731c1c0cda6a2.png)

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [August 26, 2022, 7:30am UTC](https://devforum.zoom.us/t/muteshareaudio-dont-work/74876/4 "2022-08-26T07:30:40Z")

</div>

Hey @efron.vit

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:

```javascript
let flag=false;
client.on('share-audio-change', async (payload) => {
  if (payload.state === 'on') {
    if (!flag) {
      await stream.muteShareAudio();
      flag = true;
      await stream.unmuteAudio();
    }
  }
});

```

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![efron.vit](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/efron.vit/32/33711_2.png) [@efron.vit](https://devforum.zoom.us/u/efron.vit)\
**Post date:** [August 26, 2022, 8:36am UTC](https://devforum.zoom.us/t/muteshareaudio-dont-work/74876/5 "2022-08-26T08:36:00Z")

</div>

@vic.yang Thank you, we will be waiting for the update in the new version

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [September 25, 2022, 6:36pm UTC](https://devforum.zoom.us/t/muteshareaudio-dont-work/74876/6 "2022-09-25T18:36:29Z")

</div>

Closed on September 25, 2022, 6:36pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
