Game goes silent when the alarm clock goes off

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#/, 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/

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

Thanks!
Is there any suggestions for unity else?

What is the strange problem you are seeing?

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#/, 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();
            }
        }
    }

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#/, 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.

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.

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.

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

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!

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

Thanks!
I’ll send it to Unity!

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