Question

Using Xcode 5.0 and running iOS 7.0.2 on my device.

I am using this kind of code:

AVAudioRecorder *audioRecorder;
………
[audioRecorder recordForDuration:(NSTimeInterval)5.0];
………
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag
{
        NSLog(@"audioRecorderDidFinishRecording");
}

On the simulator things are OK the method audioRecorderDidFinishRecording fires up as expected 5 seconds after a call to recordForDuration has been made. On the device though it never fires up. Why could that happen? Any idea?

I have seen similar questions on the net, but not exactly this one and more important no answer that worked for me.

Was it helpful?

Solution

In case someone else has the same issue. Here is the solution I found:

One needs the following before calling the recordForDuration method.

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];

Strangely enough this is not an issue on the simulator.

OTHER TIPS

audioRecorder.stop() needs to be called as well

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