# Any known solution for quick muting/pausing webgl audio when tab switching?

**URL:** <https://qa.fmod.com/t/any-known-solution-for-quick-muting-pausing-webgl-audio-when-tab-switching/20113>\
**Category:** Unity\
**Created:** [April 13, 2023, 1:57pm UTC](https://qa.fmod.com/t/any-known-solution-for-quick-muting-pausing-webgl-audio-when-tab-switching/20113 "2023-04-13T13:57:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SwingWren](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/swingwren/32/4797_2.png) [@SwingWren](https://qa.fmod.com/u/SwingWren)\
**Post date:** [April 13, 2023, 1:57pm UTC](https://qa.fmod.com/t/any-known-solution-for-quick-muting-pausing-webgl-audio-when-tab-switching/20113/1 "2023-04-13T13:57:01Z")

</div>

I’m trying to find a good solution to not have a bad user experience when switching tabs. I know the limitations as said in here: [Audio stutters when switching tabs in browser](https://qa.fmod.com/t/audio-stutters-when-switching-tabs-in-browser/15487) but I would like to know what possible solutions I can apply.

Right know I managed to detect the switch of tabs/minimize and then mute the audio but the downside its that its not applied fast (It takes around 1-2s for the audio to mute) and stuttering is heard. Is this the best solution available right now or there is another one that I don’t know of?

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [April 20, 2023, 2:14am UTC](https://qa.fmod.com/t/any-known-solution-for-quick-muting-pausing-webgl-audio-when-tab-switching/20113/2 "2023-04-20T02:14:14Z")

</div>

Hi - apologies for the delayed response,

I’m able to get WebGL audio to pause immediately on switching tabs using the following `MonoBehaviour` code, which is based on what `RuntimeManager` already does for `OnApplicationPause`:

```auto
    private void OnApplicationFocus(bool focus)
    {
        if (RuntimeManager.StudioSystem.isValid())
        {
            RuntimeManager.PauseAllEvents(!focus);

            if (!focus)
            {
                RuntimeManager.CoreSystem.mixerSuspend();
            }
            else
            {
                RuntimeManager.CoreSystem.mixerResume();
            }
        }
    }

```

Give it a try, and let me know if there’s any issues.
