Search code examples
objective-cios5mpmovieplayercontrollerrecordavaudiorecorder

AVAudioRecorder fails recordForDuration after MPMoviePlayerController play on iOS 5


I have weird problem on iOS5, on iOS6 it is working just fine :)

I'm able to record as much as I like using AVAudioRecorder, but if I do any playback using MPMoviePlayerController, recording fails. To be precise when I call recordForDuration (after playback) it is returning NO.

Please help!


Solution

  • If anyone experience something like this I found solution :) Before recording you need to create AVAudioSession

    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    NSError *err;
    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
    if (err)
    {
        NSLog(@"%@ %d %@", [err domain], [err code], [[err userInfo] description]);
    }
    err = nil;
    [audioSession setActive:YES error:&err];
    if (err)
    {
        NSLog(@"%@ %d %@", [err domain], [err code], [[err userInfo] description]);
    }
    

    and it should work just fine :)