Вопрос

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.

Это было полезно?

Решение

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.

Другие советы

audioRecorder.stop() needs to be called as well

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top