Hello, I’ve made an app using Unity 2022.3.26f1 and the latest fMod, I’m struggling to get it to continue to play audio in the background on an iphone when the screen is off or the phone is locked.
I understand how to do this via Signing&Capabilities, and using the correct Audio Session via AppDelegate, but can’t get it to work. It will play when the app loses focus (i.e. on home screen) but when phone locks it stops.
Is this something to do with using fMod as the audio engine instead of Unity’s?
Which AVAudiosession Category do you have set in the startUnity method in the UnityAppController.mm file?
Try replace:
[audioSession setCategory: AVAudioSessionCategoryAmbient error: nil];
with:
[audioSession setCategory: AVAudioSessionCategoryPlayback error: nil];
(Given you’ve disabled unity audio. Else you could add it outside the if statement).
And as you said, the audio background mode should be added in the capabilites.
1 Like
Thanks! I did have it set up that way; turns out the problem was a memory one- the fmod buffer size was not big enough within Unity which caused problems when the app lost focus.
1 Like
Ah, that’s good to know, if I ever run into this. Thanks for the update!
1 Like
Thank you for sharing the solution.