通过
将一些内容记录到指定文件中[[ AVAudioRecorder alloc] initWithURL:_fileURL settings:settings error:&_error];
停止录音机并成功保存文件后需要立即播放录音文件。
问题是如何何时可以读取文件并播放它。可以使用哪个委托(delegate) API?
最佳答案
设置 AVAudioRecorder
实例的委托(delegate)
AVAudioRecorder* test = [[AVAudioRecorder alloc] initWithURL:_fileURL settings:settings error:&_error];
然后实现
- (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];
}
}
}
关于ios - 如何通过成功将音频保存到文件来知道 AVAudioRecorder 何时停止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8130584/