About playing sounds in the background:
You must set the AVAudioSession category to AVAudioSessionCategoryPlayback and add an audio value to the UIBackgroundModes key in your information property list file.
NSError *setCategoryError = nil; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
I tested this code only on iOS 7 and above, so it may not work for earlier versions.
From Apple docs:
AVAudioSessionCategoryPlayback A category for playing recorded music or other sounds that are central to the successful use of your application.
When using this category, your audio application continues using the silent switch off or when the screen locks. (The Ring / Silent switch on the iPhone is called up.) To continue playing the sound when your application goes to the background (for example, when the lock screen), add the sound value to the UIBackgroundModes key in your information properties list file.
see links here and here
source share