# testSpeaker API only works once and then becomes silent

**URL:** <https://devforum.zoom.us/t/testspeaker-api-only-works-once-and-then-becomes-silent/79456>\
**Category:** Web\
**Tags:** api\
**Created:** [November 29, 2022, 4:44pm UTC](https://devforum.zoom.us/t/testspeaker-api-only-works-once-and-then-becomes-silent/79456 "2022-11-29T16:44:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brendonion](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/brendonion/32/38642_2.png) [@brendonion](https://devforum.zoom.us/u/brendonion)\
**Post date:** [November 29, 2022, 4:44pm UTC](https://devforum.zoom.us/t/testspeaker-api-only-works-once-and-then-becomes-silent/79456/1 "2022-11-29T16:44:31Z")

</div>

**Description**

Using the `testSpeaker` api, I have encountered a few problems. First, it works fine until you try stopping and starting again (it becomes silent). Secondly, if you call `destroy()`, it throws an error when you create a new testSpeaker. I based some of my code off of the react demo app, and yes, the react demo app causes the same errors too.

**Browser Console Error**

Various console errors I’ve encountered:

```auto
InvalidStateError - Failed to execute 'stop' on 'AudioScheduledSourceNode': cannot call stop without calling start first.

```

```auto
InvalidAccessError - Failed to execute 'connect' on 'AudioNode': cannot connect to an AudioNode belonging to a different audio context.

```

**Which Web Video SDK version?**

1.5.5

**Video SDK Code Snippets**

```auto
// Play default test speaker sound on selected speaker
const onTestSpeakerClick = () => {
  speakerTesterRef.current = localAudio.testSpeaker({
    speakerId: previewSpeakerSelectionId,
    onAnalyseFrequency: (value: number) => {
      setOutputLevel(Math.min(100, value))
    },
  })
  setIsPlayingAudio(true)
}

// Stop test speaker after 3 seconds
useEffect(() => {
  if (!isPlayingAudio) {
    return
  }
  setSecondsLeft(3)
  const interval = setInterval(() => {
    setSecondsLeft((prev) => {
      const newSeconds = prev - 1
      if (newSeconds <= 0) {
        clearInterval(interval)
        setIsPlayingAudio(false)
        setOutputLevel(0)
        speakerTesterRef.current?.stop()
      }
      return newSeconds
    })
  }, 1000)
}, [isPlayingAudio])

```

**To Reproduce(If applicable)**  
Steps to reproduce the behavior:

1. Start up react demo app
2. Go to preview
3. Click test speaker, it works
4. Stop speaker and test again, it is silent
5. Switch speakers and test again, still silent

**Screenshots**

N/A

**Troubleshooting Routes**

Tested on the react demo app and encountered the same issues. Followed the sample code with no luck. The errors are originating from the vSDK library as far as I can tell. No permission issues at all.

**Device (please complete the following information):**

- Device: Macbook Pro M1
- OS: macOS 12.6
- Browser: Chrome
- Browser Version 106.0.5249.119 (Official Build) (arm64)

**Additional context**

`testMicrophone` works like a charm. It is only `testSpeaker` that is giving me issues.

---

<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:** [November 30, 2022, 1:53am UTC](https://devforum.zoom.us/t/testspeaker-api-only-works-once-and-then-becomes-silent/79456/2 "2022-11-30T01:53:16Z")

</div>

Hey @brendonion

Thanks for your feedback.

It is indeed an issue, we will fix it in the next release.

Thanks  
Vic

---

<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:** [December 30, 2022, 11:53am UTC](https://devforum.zoom.us/t/testspeaker-api-only-works-once-and-then-becomes-silent/79456/3 "2022-12-30T11:53:46Z")

</div>

Closed on December 30, 2022, 11:53am UTC

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