zvjerka24
zvjerka24

Reputation: 1792

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!

Upvotes: 1

Views: 935

Answers (1)

zvjerka24
zvjerka24

Reputation: 1792

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 :)

Upvotes: 2

Related Questions