When I launch my iPhone game as soon as a sound plays the background music or podcast that is playing stops. I noticed other games allow background audio to continue to play.
How is this possible? Do I need to override a method in my App Delegate?
iosiphoneobjective c
When I launch my iPhone game as soon as a sound plays the background music or podcast that is playing stops. I noticed other games allow background audio to continue to play.
How is this possible? Do I need to override a method in my App Delegate?
Best Answer
Place this line in your
application:didFinishLaunchingWithOptions:
method of yourAppDelegate
or in general before using the audio player.According to the documentation, the
AVAudioSessionCategoryAmbient
category isIf you want also to ensure that no error occurred you have to check the return value
As a final remark, don't forget to link the
AVFoundation
framework to your project and import it.