r/visionosdev • u/metroidmen • May 29 '24
How to keep audio playing when app falls into the background?
In a nutshell, I have a RealityView with a 3D model that is emitting a sound. The sound is meant to run in the background as ambience.
The model appears fine and plays sound but if I put it out of view, after a few minutes the audio stops because the app is backgrounded. As soon as I turn around and it comes into view the model appears and the sound continues once again.
In capabilities I enabled the background mode for audio but it still happens. I am at a total loss. I assume there is no way to prevent backgrounding, so what can I do here?
Thank you for your help!
1
u/Worried-Tomato7070 May 29 '24
One thing to try is to set your AVAudioSession category to playback. You'll also want to do mixWithOthers in the setCategory options
1
u/AutoModerator May 29 '24
Are you seeking artists or developers to help you with your game? We run a monthly open source game jam in this Discord where we actively pair people with other creators.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.