One more feature that Apple has provided to iDevelopers that is very useful. If you are building something like audio player iphone application and if you want player to play even if iPhone is locked then you must use this code below:
UInt32 category = kAudioSessionCategory_MediaPlayback; //1
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (category), &category); //2
AudioSessionSetActive (true); //3
Code explanation :
1. Set the audio session category – kAudioSessionCategory_MediaPlayback.
2. Will ensure our audio playback contiues when the device is locked.
3. Activate the audio session immmediately before playback starts.
Just put this code in play method definition in implementation of your player class.
And that is all.