# Switch audio output between earpiece and headphones in react-native

**URL:** <https://devforum.zoom.us/t/switch-audio-output-between-earpiece-and-headphones-in-react-native/91416>\
**Category:** React Native\
**Tags:** video-sdk\
**Created:** [July 6, 2023, 11:32am UTC](https://devforum.zoom.us/t/switch-audio-output-between-earpiece-and-headphones-in-react-native/91416 "2023-07-06T11:32:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![o.zaoujal](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/o.zaoujal/32/50049_2.png) [@o.zaoujal](https://devforum.zoom.us/u/o.zaoujal)\
**Post date:** [July 6, 2023, 11:32am UTC](https://devforum.zoom.us/t/switch-audio-output-between-earpiece-and-headphones-in-react-native/91416/1 "2023-07-06T11:32:53Z")

</div>

**Hello world…**

I’m currently working in a project built in react-native and I’m using video sdk, I just need to know is there and option that let’s you switch audio output between earpiece and headphones (I can detect is my device connected to the headphones via bluetooth), I’ll be thankful if somebody help!

here is a part of code about how I generate speaker and silence mode

```auto
  //? set audio output
  useEffect(() => {
    if (audioOutput === 'speaker') {
      zoom.audioHelper.startAudio();
      zoom.audioHelper.setSpeaker(true);
    } else if (audioOutput === 'silence') {
      zoom.audioHelper.setSpeaker(false);
      zoom.audioHelper.stopAudio();
    } else if (audioOutput === 'earpiece') {
      zoom.audioHelper.startAudio();
      zoom.audioHelper.setSpeaker(false);
      // I need something here to force earpiece output instead of headphones even if my device is connected a headphones
    } else if (audioOutput === 'bluetooth') {
      zoom.audioHelper.startAudio();
      zoom.audioHelper.setSpeaker(false);
    }
  }, [audioOutput]);

```

---

<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:** [August 5, 2023, 11:33am UTC](https://devforum.zoom.us/t/switch-audio-output-between-earpiece-and-headphones-in-react-native/91416/2 "2023-08-05T11:33:33Z")

</div>

Closed on August 5, 2023, 11:33am UTC

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