Reputation: 152
I am trying to be able to record audio through the iPhone's microphone while simultaneously playing music from the iPod.
The recording and playback work separately, but if I try to playback from the iPod and record at the same time the recording stops.
By the way, I am not actually recording the audio to save the sound file, but merely analyzing it. It's for my app that flashes to the beat of the music you play.
Does Apple just not allow record and playback at the same time?
Upvotes: 5
Views: 3033
Reputation: 559
the problem may be you are recording audio to the same path where the playing file is saved.
try to play an audio from a url with AVAudioPlayer and you can record with AVAudioRecorder at the same time.
Cheers :) :)
Upvotes: 0
Reputation: 3823
You should be able to do this by setting the Audio Session to AVAudioSessionCategoryPlayAndRecord
. Information on this is in the Apple docs, although admittedly the Core Audio documentation is (and has always been) lacking in clarity.
Also, it's worth noting that AVAudioRecorder and AVAudioPlayer automatically set the session for you. You can wrestle control and set the session manually using the key I highlighted above.
Upvotes: 1