# Game goes silent when the alarm clock goes off

**URL:** <https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052>\
**Category:** Unity\
**Created:** [August 20, 2018, 6:48am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052 "2018-08-20T06:48:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![luzay341](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@luzay341](https://qa.fmod.com/u/luzay341)\
**Post date:** [August 20, 2018, 6:48am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/1 "2018-08-20T06:48:00Z")

</div>

This is the code in Unity, but it can’t be called when alarm clock actived and unactived.  
When alarm clock is active, the game goes silent.  
When alarm clock is closed with the game is not in background, the game keep silent.  
I’m looking for any API can be called in Unity when alarm clock actived or unactived, and the result is OnApplicationPause and OnApplicationFocus have some relation with the problem, but there can’t be called when alarm clock actived or unactived.  
I hava seen the suggestions in [https://www.fmod.com/resources/documentation-api?page=content/generated/platform\_ios/basics.html#/](https://www.fmod.com/resources/documentation-api?page=content/generated/platform_ios/basics.html#/), but it is the suggesstions for ios develop, not for unity.

This is the Code in Unity!!!

RuntimeManager.cs

void OnApplicationPause(bool pauseStatus)  
{  
if (studioSystem.isValid())  
{  
// Strings bank is always loaded  
if (loadedBanks.Count \> 1)  
PauseAllEvents(pauseStatus);

if (pauseStatus)  
{  
lowlevelSystem.mixerSuspend();  
}  
else  
{  
lowlevelSystem.mixerResume();  
}  
}  
}

我们游戏用在Unity下用Fmod，有个奇怪的问题，在ios系统，闹钟响的时候，上划关闭闹钟，然后游戏就没有声音了

---

<div class="post-metadata">

**Author:** ![mayduavongts](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@mayduavongts](https://qa.fmod.com/u/mayduavongts)\
**Post date:** [August 29, 2018, 3:03am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/2 "2018-08-29T03:03:04Z")

</div>

> [@](#):
>
> This is the code in Unity, but it can’t be called when alarm clock actived and unactived.  
> When alarm clock is active, the game goes silent.  
> When alarm clock is closed with the game is not in background, the game keep silent.  
> I’m looking for any API can be called in Unity when alarm clock actived or unactived, and the result is OnApplicationPause and OnApplicationFocus have some relation with the problem, but there can’t be called when alarm clock actived or unactived.  
> I hava seen the suggestions in [https://www.fmod.com/resources/documentation-api?page=content/generated/platform\_ios/basics.html#/](https://www.fmod.com/resources/documentation-api?page=content/generated/platform_ios/basics.html#/), but it is the suggesstions for ios develop, not for unity.
> 
> This is the Code in Unity!!!
> 
> RuntimeManager.cs
> 
> void OnApplicationPause(bool pauseStatus)  
> {  
> if (studioSystem.isValid())  
> {  
> // Strings bank is always loaded  
> if (loadedBanks.Count \> 1)  
> PauseAllEvents(pauseStatus);
> 
> if (pauseStatus)  
> {  
> lowlevelSystem.mixerSuspend();  
> }  
> else  
> {  
> lowlevelSystem.mixerResume();  
> }  
> }  
> }
> 
> 我们游戏用在Unity下用Fmod，有个奇怪的问题，在ios系统，闹钟响的时候，上划关闭闹钟，然后游戏就没有声音了

Thanks for sharing, nice post! Post really provice useful information! [http://anthaison.vn/sp/may-dua-vong-tu-dong-ts/](http://anthaison.vn/sp/may-dua-vong-tu-dong-ts/)

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [August 20, 2018, 10:30am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/3 "2018-08-20T10:30:16Z")

</div>

Hi are you following all the suggestions in [https://www.fmod.com/resources/documentation-api?page=content/generated/platform\_ios/basics.html#/](https://www.fmod.com/resources/documentation-api?page=content/generated/platform_ios/basics.html#/) ?

---

<div class="post-metadata">

**Author:** ![luzay341](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@luzay341](https://qa.fmod.com/u/luzay341)\
**Post date:** [August 21, 2018, 7:02am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/4 "2018-08-21T07:02:48Z")

</div>

> [@](#):
>
> Hi are you following all the suggestions in [https://www.fmod.com/resources/documentation-api?page=content/generated/platform\_ios/basics.html#/](https://www.fmod.com/resources/documentation-api?page=content/generated/platform_ios/basics.html#/) ?

Thanks!  
Is there any suggestions for unity else?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [August 21, 2018, 10:45pm UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/5 "2018-08-21T22:45:32Z")

</div>

What is the strange problem you are seeing?

---

<div class="post-metadata">

**Author:** ![luzay341](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@luzay341](https://qa.fmod.com/u/luzay341)\
**Post date:** [August 22, 2018, 2:26am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/6 "2018-08-22T02:26:33Z")

</div>

This is the code in Unity, but it can’t be called when alarm clock actived and unactived.  
When alarm clock is active, the game goes silent.  
When alarm clock is closed with the game is not in background, the game keep silent.  
I’m looking for any API can be called in Unity when alarm clock actived or unactived, and the result is OnApplicationPause and OnApplicationFocus have some relation with the problem, but there can’t be called when alarm clock actived or unactived.  
I hava seen the suggestions in [https://www.fmod.com/resources/documentation-api?page=content/generated/platform\_ios/basics.html#/](https://www.fmod.com/resources/documentation-api?page=content/generated/platform_ios/basics.html#/), but it is the suggesstions for ios develop, not for unity.

This is the Code in Unity!!!

RuntimeManager.cs

```
    void OnApplicationPause(bool pauseStatus)
    {
        if (studioSystem.isValid())
        {
            // Strings bank is always loaded
            if (loadedBanks.Count > 1)
                PauseAllEvents(pauseStatus);

            if (pauseStatus)
            {
                lowlevelSystem.mixerSuspend();
            }
            else
            {
                lowlevelSystem.mixerResume();
            }
        }
    }
```

---

<div class="post-metadata">

**Author:** ![luzay341](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@luzay341](https://qa.fmod.com/u/luzay341)\
**Post date:** [August 22, 2018, 2:22am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/7 "2018-08-22T02:22:44Z")

</div>

This is the code in Unity, but it can’t be called when alarm clock actived and unactived.  
When alarm clock is active, the game goes silent.  
When alarm clock is closed with the game is not in background, the game keep silent.  
I’m looking for any API can be called in Unity when alarm clock actived or unactived, and the result is OnApplicationPause and OnApplicationFocus have some relation with the problem, but there can’t be called when alarm clock actived or unactived.  
I hava seen the suggestions in [https://www.fmod.com/resources/documentation-api?page=content/generated/platform\_ios/basics.html#/](https://www.fmod.com/resources/documentation-api?page=content/generated/platform_ios/basics.html#/), but it is the suggesstions for ios develop, not for unity.

This is the Code in Unity!!!

RuntimeManager.cs

void OnApplicationPause(bool pauseStatus)  
{  
if (studioSystem.isValid())  
{  
// Strings bank is always loaded  
if (loadedBanks.Count \> 1)  
PauseAllEvents(pauseStatus);

```
            if (pauseStatus)
            {
                lowlevelSystem.mixerSuspend();
            }
            else
            {
                lowlevelSystem.mixerResume();
            }
        }
    }
```

---

<div class="post-metadata">

**Author:** ![luzay341](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@luzay341](https://qa.fmod.com/u/luzay341)\
**Post date:** [August 22, 2018, 2:25am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/8 "2018-08-22T02:25:40Z")

</div>

> [@](#):
>
> This is the code in Unity, but it can’t be called when alarm clock actived and unactived.  
> When alarm clock is active, the game goes silent.  
> When alarm clock is closed with the game is not in background, the game keep silent.  
> I’m looking for any API can be called in Unity when alarm clock actived or unactived, and the result is OnApplicationPause and OnApplicationFocus have some relation with the problem, but there can’t be called when alarm clock actived or unactived.  
> I hava seen the suggestions in [https://www.fmod.com/resources/documentation-api?page=content/generated/platform\_ios/basics.html#/](https://www.fmod.com/resources/documentation-api?page=content/generated/platform_ios/basics.html#/), but it is the suggesstions for ios develop, not for unity.
> 
> This is the Code in Unity!!!
> 
> RuntimeManager.cs
> 
> void OnApplicationPause(bool pauseStatus)  
> {  
> if (studioSystem.isValid())  
> {  
> // Strings bank is always loaded  
> if (loadedBanks.Count \> 1)  
> PauseAllEvents(pauseStatus);
> 
> ```
> if (pauseStatus)
> {
> lowlevelSystem.mixerSuspend();
> }
> else
> {
> lowlevelSystem.mixerResume();
> }
> }
> }
> 
> ```

There is no problem in Android system.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [August 24, 2018, 4:15am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/9 "2018-08-24T04:15:09Z")

</div>

It looks like interruptions don’t trigger the OnApplicationPause callback in Unity, but OnApplicationFocus does handle this.

I have tested and submitted a fix for this which will be in the next release.  
In the mean time you can find the fix on our Github repo.

> <https://github.com/fmod/UnityIntegration/commit/e25292e48d13c4e94dad176716de58c541c66a21>

---

<div class="post-metadata">

**Author:** ![luzay341](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@luzay341](https://qa.fmod.com/u/luzay341)\
**Post date:** [August 27, 2018, 11:19am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/10 "2018-08-27T11:19:28Z")

</div>

> [@](#):
>
> It looks like interruptions don’t trigger the OnApplicationPause callback in Unity, but OnApplicationFocus does handle this.
> 
> I have tested and submitted a fix for this which will be in the next release.  
> In the mean time you can find the fix on our Github repo.
> 
> [iOS - Fixed playback not resuming after alarm / call interruptions. · fmod/fmod-for-unity@e25292e · GitHub](https://github.com/fmod/UnityIntegration/commit/e25292e48d13c4e94dad176716de58c541c66a21)

As we tested, the interruptions don’t trigger OnApplicationPause or OnApplicationFocus.  
I add your fix to my project, it does’t work, the OnApplicationPause and OnApplicationFocus callback can’t be triggered.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [August 27, 2018, 11:25pm UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/11 "2018-08-27T23:25:03Z")

</div>

That is strange, I have been testing the alarm interrupt and it was triggering the Focus callback.

Can you provide some more information:

- Unity version
- FMOD version
- Testing device

---

<div class="post-metadata">

**Author:** ![luzay341](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@luzay341](https://qa.fmod.com/u/luzay341)\
**Post date:** [August 28, 2018, 1:29am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/12 "2018-08-28T01:29:15Z")

</div>

Unity 2017.2.0p4  
FMOD Studio Unity Integration: 1.10.02  
Device: iPad mini2, iPhone 8 plus, iPhone 6 Plus …  
iOS:11.2,9.4,10.x  
Most ios device have the problem.

Thanks!

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [August 29, 2018, 1:08am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/13 "2018-08-29T01:08:31Z")

</div>

If the OnApplicationFocus isn’t being triggered then there may be an issue with Unity.  
[https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html)

---

<div class="post-metadata">

**Author:** ![luzay341](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@luzay341](https://qa.fmod.com/u/luzay341)\
**Post date:** [August 30, 2018, 1:44am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/14 "2018-08-30T01:44:40Z")

</div>

Thanks!  
I’ll send it to Unity!

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 4, 2019, 3:07am UTC](https://qa.fmod.com/t/game-goes-silent-when-the-alarm-clock-goes-off/14052/15 "2019-09-04T03:07:19Z")

</div>

Any news on this ? OnApplicationFocus isn’t called for me either
