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?
0
votes
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.