Reputation: 127913
Record something to the specified file by
[[ AVAudioRecorder alloc] initWithURL:_fileURL settings:settings error:&_error];
Need to play the recorded file immediately once stop the recorder and save file successfully.
Question is how to when is okay to read the file and playback it. Which delegate api could be used ?
Upvotes: 0
Views: 963
Reputation: 4131
set the delegate of your AVAudioRecorder
instance
AVAudioRecorder* test = [[AVAudioRecorder alloc] initWithURL:_fileURL settings:settings error:&_error];
then implement
- (void) audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag
{
// play the recorded audio here
if (flag)
{
NSError* error;
AVAudioPlayer* player = [[[AVAudioPlayer alloc] initWithContentsOfURL:[recorder url] error:&error] autorelease];
if (!error)
{
[player play];
}
}
}
Upvotes: 1
Reputation: 2521
Have you tried using
- (void) audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag
{
// Play the audio
}
Upvotes: 0