# The speaker sometimes does not work when using Puppeteer with a fake media device

**URL:** <https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367>\
**Category:** Web\
**Created:** [May 6, 2025, 3:37am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367 "2025-05-06T03:37:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 6, 2025, 3:37am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/1 "2025-05-06T03:37:50Z")

</div>

**Description**  
We’re using `Puppeteer` to launch a `Chrome` instance with the `--use-fake-device-for-media-stream` flag. However, we occasionally encounter an issue where the speaker doesn’t work—we can’t hear the other participants speaking.

Upon checking the Zoom management page, we found that the microphone status showed an error: `getUserMedia failed`.

Could you help investigate the cause of this issue? It only occurs intermittently; in most cases, everything works as expected.

Here is the session ID for reference: `3SS0uapFTLyfj7n33YeFGA==`

**Which Web Video SDK version?**  
2.1.0

**Video SDK Code Snippets**

```auto
  async startAudio(mute, speakerOnly) {
    try {
      if (speakerOnly) {
        await state.mediaStream.startAudio({ speakerOnly: true });
      } else {
        await state.mediaStream.startAudio({ mute: mute });
      }
    } catch (error) {
      Logger.error('[VIDEO-SDK JS] startAudio error', error);
    }
  }

```

**Screenshots**

 ![Screenshot 2025-05-05 at 12.06.25 (1)](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/3/9/396c60cdd55e3e20dd46f7432bff6b474f1615ce.png)

**Device**

- OS: Linux
- Browser: Chrome: GoogleChromeSAB
- Browser Version: 134

---

<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:** [May 6, 2025, 7:59am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/2 "2025-05-06T07:59:15Z")

</div>

Hey @lmtruong1512

Thanks for your feedback.

> 3SS0uapFTLyfj7n33YeFGA==

After analyzing the log, we found that when attempting to capture audio, the browser returned a `NotReadableError`. This may be due to the improper configuration of the fake media. Did you also set the `--use-file-for-fake-audio-capture` argument?

> **[MediaDevices: getUserMedia() method - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions)**
>
> The getUserMedia() method of the MediaDevices interface prompts the user for permission to use a media input which produces a MediaStream with tracks containing the requested types of media.

> **[Testing | WebRTC](https://webrtc.github.io/webrtc-org/testing/)**
>
> WebRTC is a free, open project that enables web browsers with Real-Time Communications (RTC) capabilities via simple JavaScript APIs. The WebRTC components have been optimized to best serve this purpose.

If your goal is only to hear remote users’ audio, you can set the `speakerOnly` option to `true`.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 6, 2025, 8:34am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/3 "2025-05-06T08:34:54Z")

</div>

@vic.yang Thanks for your response.

We only want to hear remote users’ audio. If I set the `speakerOnly` option to `true`, will `startAudio` still work and allow us to hear others even if the browser throws a `NotReadableError`?  
Or does setting `speakerOnly = true` ensure that the `NotReadableError` will never occur?

---

<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:** [May 6, 2025, 8:51am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/4 "2025-05-06T08:51:46Z")

</div>

Hi @lmtruong1512

> If I set the `speakerOnly` option to `true` , will `startAudio` still work and allow us to hear others even if the browser throws a `NotReadableError` ?

If the `speakerOnly` option is set to true, we will not capture audio, only play the remote audio, so the `NotReadableError` will not occur.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 6, 2025, 11:56am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/5 "2025-05-06T11:56:49Z")

</div>

We got it, thanks, @vic.yang

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 8, 2025, 8:48am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/6 "2025-05-08T08:48:09Z")

</div>

Hi @vic.yang,

Could you help investigate why we’re unable to render the video stream from other users?  
Could this be related to the microphone issue mentioned earlier?

This is the sessionId: `rsNXr1RbS0uTT1p+GkzrKA==`

Thank you in advance!

---

<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:** [May 8, 2025, 9:33am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/7 "2025-05-08T09:33:34Z")

</div>

Hi @lmtruong1512

> rsNXr1RbS0uTT1p+GkzrKA==

After analyzing the logs, we found that the user experienced significant delay, which could be the cause of the video render issue.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 8, 2025, 10:20am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/8 "2025-05-08T10:20:23Z")

</div>

> [@vic.yang](#):
>
> After analyzing the logs, we found that the user experienced significant delay, which could be the cause of the video render issue.

@vic.yang Could you help troubleshoot whether the delay was caused by a Zoom SDK problem, a network issue, or resource limitations on the client side (e.g., memory or CPU usage)?

---

<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:** [May 9, 2025, 1:29am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/9 "2025-05-09T01:29:36Z")

</div>

Hi @lmtruong1512

> rsNXr1RbS0uTT1p+GkzrKA==

Around 5 minutes after the session started, the uplink and downlink of UserID: 16778240 dropped sharply, which could be the cause of the video issue.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 10, 2025, 1:14pm UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/10 "2025-05-10T13:14:27Z")

</div>

@vic.yang Could you help investigate the issue where both the **microphone** and **speaker** are not accessible for the `RECORDING_BOT` when starting audio with the `speakerOnly` option set to `true` in the following sessions:

`9aF8YPhEQgaHxr4hoZwG3w==`  
`UsIoxcsDSgerPxuK2NZwIQ==`

```auto
await state.mediaStream.startAudio({ speakerOnly: true });

```

Here is the relevant information from the **Zoom Management Page** :

 ![Screenshot 2025-05-10 at 20.05.54](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/8/4/840f1ef18ae7acd7d86da0e55bcdd667e690cdd3.jpeg)

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 11, 2025, 7:33am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/11 "2025-05-11T07:33:09Z")

</div>

@vic.yang In that case, is the RECORDING\_BOT able to hear other participants speaking?

---

<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:** [May 12, 2025, 6:59am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/12 "2025-05-12T06:59:59Z")

</div>

Hi @lmtruong1512

> 9aF8YPhEQgaHxr4hoZwG3w==  
> UsIoxcsDSgerPxuK2NZwIQ==

After analyzing the logs, these two BOT users did not successfully start audio, possibly due to the browser’s autoplay policy requiring user interaction.

You can listen for the `auto-play-audio-failed` event.

> **[Video SDK - web - Event handling](https://developers.zoom.us/docs/video-sdk/web/handle-events/#auto-play-audio-failed)**
>
> The Zoom Developer Platform is an open platform that allows third-party developers to build applications and integrations upon Zoom’s video-first unified communications platform.

If you’re using Puppeteer, consider adding the launch flag `--autoplay-policy=no-user-gesture-required`.

> <https://github.com/puppeteer/puppeteer/issues/6774>
>
> I'm trying to play spotify via puppeteer. Because Chromium seems to not like aud…io file, I use chrome. 
> 
> In headful mode, everything work well, but when I switch to headless mode, the song doesn't play at all (as if I was using Chromium??).
> 
> I though headless would had the same feature than headfull. I also tested with Edge but same problem.
> 
> Here is my code 
> 
> \`\`\`
> var puppeteer = require('puppeteer');
> var util = require("./util.js");
> 
> async function initBrowser(){
> let browser = await puppeteer.launch({
> headless: false, //permet de voir
> slowMo: 15,
> executablePath: 'C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe',
> //
> //args: (url)?\[\`--proxy-server=${url}\`\]:\[\]
> });
> return browser;
> }
> 
> 
> exports.main = async function(){
> let browser = await initBrowser();
> let webPage = await browser.newPage();
> await webPage.goto("https://accounts.spotify.com/en/login/", { waitUntil: "load", timeout: 30000});
> //login
> await webPage.type('#login-username', 'LOGIN');
> await webPage.type('#login-password', 'PSWD');
> await webPage.click('#login-button');
> await util.sleep(1000);
> 
> //music
> await webPage.goto("https://open.spotify.com/artist/3nFkdlSjzX9mRTtwJOzDYB", { waitUntil: "load", timeout: 30000});
> await util.sleep(2500);
> await webPage.click('#onetrust-accept-btn-handler'); //accept cookie
> await util.sleep(1000);
> await webPage.click('div\[data-testid="action-bar-row"\] button\[data-testid="play-button"\]'); //click on play
> await webPage.screenshot({ path: 'test.png' })
> }
> \`\`\`
> 
> Am I really still using Chrome in headless mode?

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 12, 2025, 8:57am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/13 "2025-05-12T08:57:54Z")

</div>

@vic.yang Do you know why this happens randomly with the same code? Could it be related to the timing of the `startAudio` call — maybe it’s being called too soon?"

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/3/8/3862ac2f983f6774a58e020aef125e3900b4260f.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:** [May 12, 2025, 9:19am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/14 "2025-05-12T09:19:35Z")

</div>

Hi @lmtruong1512

> If `stream.startAudio` is called immediately upon joining a session, it might fail. Use the `auto-play-audio-failed` event to get notified of this issue so you can prompt users to interact with the page to restore audio.

‘_Called immediately upon joining a session_’ here means there’s no opportunity for user interaction between joining the session and calling `startAudio`.

For more details on auto-play policy, you can refer to the documentation on MDN.

> **[Autoplay guide for media and Web Audio APIs - Media technologies on the web |...](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Autoplay#autoplay_availability)**
>
> Automatically starting the playback of audio (or videos with audio tracks) immediately upon page load can be an unwelcome surprise to users. While autoplay of media serves a useful purpose, it should be used carefully and only when needed. In order...

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 12, 2025, 9:58am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/15 "2025-05-12T09:58:31Z")

</div>

@vic.yang Thank you for the response.

May I ask a bit more? Is it possible that `startAudio` sometimes doesn’t return an error directly, and instead we need to listen for the `auto-play-audio-failed` event? Similarly, for video — in cases where errors aren’t caught by `startVideo`,…— how should I handle those situations?

---

<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:** [May 12, 2025, 10:32am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/16 "2025-05-12T10:32:41Z")

</div>

Hi @lmtruong1512

`startAudio` has a timeout mechanism — if it fails to join audio within 40 seconds, it will return a timeout error.

When auto-play requirements aren’t met, the Video SDK interrupts the join process and emits the `auto-play-audio-failed` event. In that event, simply guiding the user to interact with the page will allow the SDK to resume the join process.

`startVideo` doesn’t have this issue, as browsers don’t impose autoplay restrictions on video capture.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 13, 2025, 8:21am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/17 "2025-05-13T08:21:43Z")

</div>

@vic.yang Continue follow the reason why BOT users sometimes fail to start audio:

> it may be due to the browser’s autoplay policy, which requires user interaction before playing audio.

To start a BOT joining a meeting, we launch a separate EC2 instance for each BOT using a headless browser, which joins the meeting without any manual user interaction. However, this issue only occurs in rare cases — most BOT sessions do not encounter autoplay policy errors.

At this time, we haven’t been able to reliably reproduce the error, which makes it difficult to pinpoint and address the root cause with supporting evidence. Do you have any suggestions or recommendations that might help us investigate further? Thank you very much!

---

<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:** [May 13, 2025, 10:22am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/18 "2025-05-13T10:22:26Z")

</div>

Hi @lmtruong1512

Did you try the `--autoplay-policy=no-user-gesture-required` launch option?

As for the random cases, they still need to be investigated individually.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 13, 2025, 10:56am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/19 "2025-05-13T10:56:25Z")

</div>

> Did you try the --autoplay-policy=no-user-gesture-required launch option?

@vic.yang Thank you for your response.

Our problem is that we haven’t been able to reproduce the error to confirm whether it’s actually caused by the autoplay policy (`user-gesture-required`). Because of this, we’re uncertain if adding `--autoplay-policy=no-user-gesture-required` will fully resolve the issue.

In normal cases, when we check the autoplay policy via `about://media-engagement`, it already shows `no-user-gesture-required`—even without explicitly setting the flag.

 ![Screenshot 2025-05-13 at 17.49.45](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/a/6a40c3086362e3e045fbc19534ac8889f922a213.png)

We want to avoid this bug occurring again in our production environment. Do you have any suggestions on how to reproduce this issue?

---

<div class="post-metadata">

**Author:** ![lmtruong1512](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lmtruong1512/32/59233_2.png) [@lmtruong1512](https://devforum.zoom.us/u/lmtruong1512)\
**Post date:** [May 14, 2025, 4:42am UTC](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367/21 "2025-05-14T04:42:32Z")

</div>

@vic.yang

1. Could you recommend the best practice for when to start audio?  
Should we call `startAudio` immediately after joining the session, or wait for a specific event?
2. Is it safe to call `stream.startAudio` and `stream.switchSpeaker` in parallel?  
Are there any potential issues, and what would be the recommended approach for this scenario?

Thank you in advance!

[Next page](https://devforum.zoom.us/t/the-speaker-sometimes-does-not-work-when-using-puppeteer-with-a-fake-media-device/132367.md?page=2)
