# Safari Audio Not Working On Web SDK 1.4.0

**URL:** <https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664>\
**Category:** Web\
**Created:** [August 22, 2022, 5:47pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664 "2022-08-22T17:47:24Z")\
**Posts on this page:** 16\
**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:** [August 22, 2022, 5:47pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/1 "2022-08-22T17:47:24Z")

</div>

**Description**

Hi Zoom Team,

I read through a related topic (#69650 - Audio not joining in Safari) and I am still encountering the same issue where Safari audio simply does not work. I’ve tried to start audio automatically and with a button press but still no progress. I am not getting any console error oddly enough.

Any help here would be immensely appreciated!

P.S.  
Apologies in advance for creating the same ticket but the previous one was closed.

**Browser Console Error**  
N/A

**Which Web Video SDK version?**  
Initially - 1.2.7  
Later on - 1.4.0

**Video SDK Code Snippets**

**automatically:**

```auto
if (decode && encode) {
   try {
     stream.startAudio({ autoStartAudioInSafari: true });
   } catch (err) {
     console.warn(err);
   }
}

```

**button press:**

```auto
if (decode && encode) {
  stream.startAudio()
}

```

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

1. Follow the documentation for `startAudio` on Safari
2. Doesn’t work

**Screenshots**  
N/A

**Troubleshooting Routes**

> [@Audio not joining in Safari](https://devforum.zoom.us/t/audio-not-joining-in-safari/69650/8):
>
> Hey @tommy / @vic.yang, Just a quick FYI, this is happening to me too on Safari 15.4. I’ve also implemented something such that if the audio fails, I trigger a retry by the user clicking ‘retry’ to start the audio. mediaStream.startAudio().catch(() =\> // show audio retry modal code). Interestingly, this all works perfectly on iOS Safari for me. Cheers, Nick

> **[Stream | Zoom Video SDK for Web - 1.6.0](https://marketplacefront.zoom.us/sdk/custom/web/modules/stream.html#startaudio)**
>
> Documentation for Zoom Video SDK for Web - 1.6.0

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

- Device: M1 Macbook Pro
- OS: macOS 12.2.1
- Browser: Safari
- Browser Version 15.3 (17612.4.9.1.8)

**Additional context**  
I am testing locally on the same machine between a Chrome user and a Safari user. If audio was working, I’d hear an echo.

---

<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 23, 2022, 1:53am UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/2 "2022-08-23T01:53:20Z")

</div>

Hey @brendonion

Could you serve your webpage on a web server? Sometimes the Safari audio cannot work in the local environment.  
And could you take a look at our [sample app](https://github.com/zoom/videosdk-web-sample/tree/master/purejs-demo)?

Thanks  
Vic

---

<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:** [September 1, 2022, 8:42pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/3 "2022-09-01T20:42:09Z")

</div>

Hi Vic.

I tested again on a hosted environment and the audio is still not working. I’m logging everything and it _should_ work, but doesn’t.

```auto
if (encode && decode) {
    stream
         .startAudio()
         .then(() => console.log("Safari audio initialized successfully!"))
         .catch((e) => console.log("Safari audio failed to initialize: ", e))
} else {
    console.log("Safari audio has not been initialized...")
}

```

And the console returns “Safari audio initialized successfully!”

Any ideas here?

Thank you.

---

<div class="post-metadata">

**Author:** ![parker](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/parker/32/40768_2.png) [@parker](https://devforum.zoom.us/u/parker)\
**Post date:** [September 2, 2022, 2:00am UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/4 "2022-09-02T02:00:20Z")

</div>

Hey Brendan, we had lots of issues with waiting for the Stream to finish initializing before we were able to call startAudio successfully. Is it possible stream is null or undefined right before your startAudio is called? Recommend trying to log the `stream` in your pseudocode example to check for that scenario.

---

<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:** [September 2, 2022, 3:25pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/5 "2022-09-02T15:25:49Z")

</div>

Hi Parker,

No it’s not possible the stream is null or undefined. I check the stream value before this gets called and it’s getting to the `.then` promise handler. I can try logging stream just in case though. Any other ideas here would be greatly appreciated 🙂 .

Thank you

---

<div class="post-metadata">

**Author:** ![gourishmesta1993](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gourishmesta1993/32/39300_2.png) [@gourishmesta1993](https://devforum.zoom.us/u/gourishmesta1993)\
**Post date:** [September 6, 2022, 5:17am UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/6 "2022-09-06T05:17:16Z")

</div>

Hi @brendonion

how do you set encode and decode variables?

I hope you are using “media-sdk-change” event and then using the below code to set the encode and decode variable

```auto
const { action, type, result } = payload;
    if (type === "audio" && result === "success") {
      if (action === "encode") {
        audioEncode = true;
      } else if (action === "decode") {
        audioDecode = true;
      }
    }

```

For me this setup works on safari browser.

---

<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:** [September 6, 2022, 3:39pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/7 "2022-09-06T15:39:44Z")

</div>

Hi @gourishmesta1993

Our code looks similar to this:  
(using redux as a local store)

```auto
// file 1 (watch for media changes)
client.on("media-sdk-change", onMediaSDKChange)

const onMediaSDKChange = useCallback((payload) => {
    const { action, type, result } = payload
    const payload = { type: type, action: action, result: result === "success" } // converts to boolean
    dispatch(setMediaShape(payload))
}, [])

// file 2 (redux action)
const setMediaShape = (state, action) => {
    const mediaShape = state.mediaShape
    const mediaType = action.payload.type
    const mediaShapeAction = action.payload.action
    if (mediaType && mediaShapeAction) {
        mediaShape[mediaType][mediaShapeAction] = action.payload.result
    }
}

// file 3 (button click)
const onAudioClick = useCallback(() => {
    if (isStartedAudio) {
      dispatch(setIsMuted(!isMuted))
    } else {
      // this is where audio is triggered
      dispatch(setIsStartedAudio(true))
      dispatch(setIsMuted(false))
    }
}, [mediaStream, isStartedAudio, isMuted])

// file 4 (react hook)
useEffect(() => {
    if (isStartedAudio === null) {
      return
    }

    const isCurrentUserStartedAudio = zmClient.getCurrentUserInfo()?.audio.length > 0 && isStartedAudio

    const handleSafariAudio = () => {
      if (mediaShape.audio.encode && mediaShape.audio.decode) {
        mediaStream
          .startAudio()
          .then(() => console.log("Safari audio initialized successfully!")) // gets here successfully, still no audio
          .catch((e) => console.log("Safari audio failed to initialize: ", e))
      } else {
        console.log("Safari audio has not been initialized...")
      }
    }

    if (isStartedAudio && mediaStream) {
      if (!isCurrentUserStartedAudio) {
        if (isSafari) {
          handleSafariAudio()
        } else {
          mediaStream.startAudio()
        }
      }

      if (isCurrentUserStartedAudio) {
        if (isMuted) {
          mediaStream.muteAudio()
        } else {
          mediaStream.unmuteAudio()
        }
      }
    }
  }, [mediaStream, isStartedAudio, isMuted, zmClient, mediaShape])

```

Maybe the `useEffect` above is being called a couple times and that is causing an issue? I’m not sure but I hope this clears things up for how we are handling the audio logic.

Thank you.

---

<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:** [September 7, 2022, 3:04am UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/8 "2022-09-07T03:04:15Z")

</div>

Hey @brendonion

As the [document](https://marketplace.zoom.us/docs/sdk/video/web/essential/audio/#start-audio) mentioned, `stream.startAudio` should be in the event handler on Safari. So the code can be modified like this:

```javascript
const onAudioClick = useCallback(() => {
    if (isStartedAudio) {
      if (!isMuted) {
        mediaStream.muteAudio()
      } else {
        mediaStream.unmuteAudio()
      }
    } else {
      if (isSafari) {
        handleSafariAudio()
      } else {
        mediaStream.startAudio()
      }
    }
}, [mediaStream, isStartedAudio, isMuted])

```

Thanks  
Vic

---

<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:** [September 7, 2022, 9:29pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/9 "2022-09-07T21:29:49Z")

</div>

@vic.yang

Tried that and still nothing. Console logs successfully strangely enough. I’m running out of ideas here 😓

---

<div class="post-metadata">

**Author:** ![gourishmesta1993](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gourishmesta1993/32/39300_2.png) [@gourishmesta1993](https://devforum.zoom.us/u/gourishmesta1993)\
**Post date:** [September 8, 2022, 3:53am UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/10 "2022-09-08T03:53:06Z")

</div>

@brendonion  
How do u check isSafari?

And did u try adding the below code after @vic.yang gave u the fix?

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

```

---

<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:** [September 8, 2022, 6:48pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/11 "2022-09-08T18:48:30Z")

</div>

@gourishmesta1993

```auto
const isSafari = navigator.userAgent.indexOf('Safari') > -1 && navigator.userAgent.indexOf('Chrome') === -1

```

It is running the code. It gets to `console.log("Safari audio initialized successfully!")` but still silence. Even tried the button click callback with `{autoStartAudioInSafari: true}` and still no luck.

---

<div class="post-metadata">

**Author:** ![gourishmesta1993](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gourishmesta1993/32/39300_2.png) [@gourishmesta1993](https://devforum.zoom.us/u/gourishmesta1993)\
**Post date:** [September 9, 2022, 4:01am UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/12 "2022-09-09T04:01:50Z")

</div>

@brendonion  
can u log the content of mediaShape object once handleSafariAudio is called?  
just want to cross check the data of mediaShape object

Thank You  
@gourishmesta1993

---

<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:** [September 9, 2022, 8:04pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/13 "2022-09-09T20:04:58Z")

</div>

@gourishmesta1993

```auto
{
  audio: {encode: true, decode: true},
  video: {encode: true, decode: true},
  share: {encode: true, decode: true}
}

```

---

<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:** [September 15, 2022, 4:48pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/14 "2022-09-15T16:48:54Z")

</div>

Another update:

I tried the demo react app on localhost with two safari browsers. Oddly enough the Local Preview echoed just fine, but joining a Subsession for both browsers the audio is still void. Very odd.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/e/b/eb27bce92ac04c91969b95e3e5595c42dd835325.png)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/5/6/568ecf264a20dd07e17b97dc31d6fb6a36198b3d.jpeg)

---

<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:** [September 15, 2022, 11:57pm UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/15 "2022-09-15T23:57:01Z")

</div>

Hey @brendonion

In-session audio on the localhost environment of Safari may not work, it’s a known issue. As I mentioned above, could you test it on the Web server?

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:** [October 16, 2022, 9:57am UTC](https://devforum.zoom.us/t/safari-audio-not-working-on-web-sdk-1-4-0/74664/16 "2022-10-16T09:57:43Z")

</div>

Closed on October 16, 2022, 9:57am UTC

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