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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Place this line in your
application:didFinishLaunchingWithOptions:method of yourAppDelegateor in general before using the audio player.According to the documentation, the
AVAudioSessionCategoryAmbientcategory 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
AVFoundationframework to your project and import it.