Question

I have used AVAudioRecorder. The recorder is not recording when i come from background.

My Scenario is

  1. Start recording press home button (Recording stopped)

  2. Open my app the recorder is still recording (Checked by recorder.isRecording is YES)

  3. Stop the recording and playing the recorded audio plays only what recorded before my app goes background.

  4. I am recoding 5sec -> app goes background -> comes fore foreground -> record another 5 secs -> play the audio the audio plays only the first 5 secs.

While recording I am checking the size of the file path given to the audio recorder(By NSTimer) the file size is not increased after come from background but still the recorder status is recording

Can any one point out what is the mistake. Thanks

Note: in ios6 there is no problem it plays entire audio that is entire 10 sec it comes only in ios7

Was it helpful?

Solution

So if you dont want to record in the background and you only want to append your recording before and after going to background, pause your recorder in applicationWillEnterBackground (or applicationWillResignAcive) and when you come back form background, continue your recording and you'd be fine. (You can have notifications letting your class which is recording know about those life cycle delegate methods.) But if you want to record in the background you need to turn on Background Mode: Audio and Airplay in your app settings -> Capabilities. But thats another story.

OTHER TIPS

You should check AVAudioSessionDelegate delegate method. Audio recording will stop during phone call

- (void)beginInterruption{

}
-(void)endInterruption{
}

You can continue background recording. Add the background modes as seen in image

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top