0
votes

I create a .caf audio file using AVAudioRecorder and if I try and play it back using AVAudioPlay I get no sound on the iPhone (if played in simulator works fine). If I close my application and reopen the file plays fine. Also I am not able to adjust the phone volume after recording unless I close and reopen my application. Any ideas?

2
i am having the same problem. I guess the problem is in recording as the correct settings are not applied.Biranchi

2 Answers

4
votes

Was facing the same problem. Solved the problem by setting the AVAudioSession category to AVAudioSessionCategoryPlayback mode. This is my working code:

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
audioSession.delegate = self;
[audioSession setCategory:AVAudioSessionCategoryPlayback error:NULL];
[audioSession setActive: YES error: nil];

Also make sure that the audio recording has been finished successfully by implementing:

   -(void) audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag
{
    NSLog(@"Recording success:%@",flag ? @"YES" : @"NO");
}

And check that you have added <AVAudioSessionDelegate,AVAudioRecorderDelegate,AVAudioPlayerDelegate>

in your interface declaration.

0
votes

I have the same problem with a aac file. I used ima4 before which worked perfectly! I guess the difference is, that aac is hardware and ima4 software decoded. Did you try to reinitialize the player when the file behind got rerecorded? That worked for me!

Markus