How to record & play music on iPhone music App at a same time

I'm making an iOS application in which I'm using AVAudioRecorder to record outside audio and calculating power through averagePowerForChannel function. When my app goes in background everything goes well but when I start song using iPhone speakers my recording stops. Then I've used following code : AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; Now when I play music from iPhone music app it plays without interrupting recording but plays in very low volume. I want to turn ON the iphone music using speakers ( liek a normal sound coming from Iphone speakers) and Microphone at the same time so that microphone can listen the amplitude from the iphone speakers.

How to record & play music on iPhone music App at a same time
 
 
Q