Reputation: 11
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?
Upvotes: 0
Views: 2156
Reputation: 2623
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.
Upvotes: 4
Reputation: 4038
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
Upvotes: 0