I am currently encountering a similar issue as in this post,
but my platform is Unity WebGL.
https://qa.fmod.com/t/fmod-unity-ios-no-sound-after-app-resume-or-ad-even-after-upgrading-to-2-02-28/22836
My WebGL is embedded in an iOS app.
The problem is that after minimizing the app window and returning,
the sound disappears. However, there are two situations where the sound recovers:
-
I trigger the iOS side to play an ad via JSLib, and the sound recovers after returning.
-
Repeatedly minimizing and returning has a low probability of recovering the sound effects.
I trigger the focus using a JSLib web method,
because Unity’s OnApplicationFocus often doesn’t work.
I have configured the buffer size with System::setDSPBufferSize(1024, 4),
and also tried 4096, but it still doesn’t solve this problem.
Is there any progress on this issue? Thank you
unity C#
public void OnFocusGained()
{
Debug.Log("Focus Gained");
FMODUnity.RuntimeManager.CoreSystem.mixerResume();
FMODUnity.RuntimeManager.CoreSystem.update();
}
public void OnFocusLost()
{
Debug.Log("Focus Lost");
FMODUnity.RuntimeManager.CoreSystem.mixerSuspend();
FMODUnity.RuntimeManager.CoreSystem.update();
}
Focus.jslib
mergeInto(LibraryManager.library, {
InitFocusListener_j: function() {
try {
document.addEventListener('visibilitychange', function() {
if (!document.hidden) {
SendMessage('unitygameobject', 'OnFocusGained');
} else {
SendMessage('unitygameobject', 'OnFocusLost');
}
});
console.log("Visibility listener initialized");
} catch (error) {
console.error("Failed to initialize visibility listener: " + error);
}
}
});
The method to trigger ads is that I use JSLib to call the iOS native side.
The iOS side then calls the ad through the AdMob plugin,
which overlays a window on top of my WebGL.
The overlay window closes only after the ad ends.