Ios 如何通过将音频成功保存到文件来知道AVAudioRecorder何时停止?
通过将某些内容记录到指定的文件中Ios 如何通过将音频成功保存到文件来知道AVAudioRecorder何时停止?,ios,avaudiorecorder,avaudiosession,Ios,Avaudiorecorder,Avaudiosession,通过将某些内容记录到指定的文件中 [[ AVAudioRecorder alloc] initWithURL:_fileURL settings:settings error:&_error]; 一旦停止录音机并成功保存文件,需要立即播放录制的文件 问题是如何确定何时可以读取文件并播放它。可以使用哪个代理api?您是否尝试过使用 - (void) audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successful
[[ AVAudioRecorder alloc] initWithURL:_fileURL settings:settings error:&_error];
一旦停止录音机并成功保存文件,需要立即播放录制的文件
问题是如何确定何时可以读取文件并播放它。可以使用哪个代理api?您是否尝试过使用
- (void) audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag
{
// Play the audio
}
设置
AVAudioRecorder
实例的委托
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];
}
}
}