# Sounds playing in background when Ads are loaded. iOS Unity build

**URL:** <https://qa.fmod.com/t/sounds-playing-in-background-when-ads-are-loaded-ios-unity-build/21727>\
**Category:** Unity\
**Created:** [June 6, 2024, 11:17am UTC](https://qa.fmod.com/t/sounds-playing-in-background-when-ads-are-loaded-ios-unity-build/21727 "2024-06-06T11:17:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgesota](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@rgesota](https://qa.fmod.com/u/rgesota)\
**Post date:** [June 6, 2024, 11:17am UTC](https://qa.fmod.com/t/sounds-playing-in-background-when-ads-are-loaded-ios-unity-build/21727/1 "2024-06-06T11:17:48Z")

</div>

I am trying to pause sounds when ads are playing. I am using Appslovin Max SDK for ads.  
Sounds should not play when ads are playing.

---

<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:** [June 7, 2024, 4:16am UTC](https://qa.fmod.com/t/sounds-playing-in-background-when-ads-are-loaded-ios-unity-build/21727/2 "2024-06-07T04:16:44Z")

</div>

FMOD will not automatically stop playing audio when interrupted by other software like ad integrations.

[`RuntimeManager.CoreSystem.mixerSuspend();`](https://www.fmod.com/docs/2.02/api/core-api-system.html#system_mixersuspend) should be called when an ad starts playing, and [`RuntimeManager.CoreSystem.mixerResume();`](https://www.fmod.com/docs/2.02/api/core-api-system.html#system_mixerresume) when an ad stops playing and you want FMOD audio to return. You may need to call this manually from your own code when you start/stop playing an ad, or Appslovin Max SDK may offer callbacks for you to tie the suspend and resume calls to.

---

<div class="post-metadata">

**Author:** ![baturalpcetin](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/baturalpcetin/32/2977_2.png) [@baturalpcetin](https://qa.fmod.com/u/baturalpcetin)\
**Post date:** [October 23, 2024, 9:56am UTC](https://qa.fmod.com/t/sounds-playing-in-background-when-ads-are-loaded-ios-unity-build/21727/3 "2024-10-23T09:56:29Z")

</div>

```
    #if (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS) && !UNITY_EDITOR
    [AOT.MonoPInvokeCallback(typeof(Action<bool>))]
    private static void HandleInterrupt(bool began)
    {
        if (Instance.studioSystem.isValid())
        {
            // Strings bank is always loaded
            if (Instance.loadedBanks.Count > 1)
                PauseAllEvents(began);

            if (began)
            {
                Instance.coreSystem.mixerSuspend();
            }
            else
            {
                Instance.coreSystem.mixerResume();
            }
        }
    }

```

#if (UNITY\_IOS || UNITY\_TVOS || UNITY\_VISIONOS) && !UNITY\_EDITOR  
[DllImport(“\_\_Internal”)]  
private static extern void RegisterSuspendCallback(Action func);  
#endif

Allow this code in runtimemanager to be done automatically?

---

<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:** [October 28, 2024, 4:19am UTC](https://qa.fmod.com/t/sounds-playing-in-background-when-ads-are-loaded-ios-unity-build/21727/4 "2024-10-28T04:19:06Z")

</div>

The code in RuntimeManager that you’ve linked cannot be done automatically.

For iOS system suspend/resume, we specifically subscribe to a number of iOS system notifications that we use to call the `HandleInterrupt()` function that you’ve pointed out - the code for this can be found at `./Assets/Plugins/FMOD/platform_ios.mm`.

This works fine for system interruptions, but since ad integrations use their own interruptions, if you need to suspend and resume FMOD audio you’re required to handle `mixerSuspend()`/`mixerResume()` yourself. Modifying `RuntimeManager()` to make use of the existing code in some way would be one method of doing this.
