我正面临AVAudioRecorder的一个奇怪问题。在我的应用程序中,我需要录制音频并播放它。我正在创建我的播放器:使用AVAudioRecorder的问题
if(recorder)
{
if(recorder.recording)
[recorder stop];
[recorder release];
recorder = nil;
}
NSString * filePath = [NSHomeDirectory() stringByAppendingPathComponent: [NSString stringWithFormat:@"Documents/%@.caf",songTitle]];
NSDictionary *recordSettings = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0],AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatAppleIMA4],AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax],AVEncoderAudioQualityKey,nil];
recorder = [[AVAudioRecorder alloc] initWithURL: [NSURL fileURLWithPath:filePath] settings: recordSettings error: nil];
recorder.delegate = self;
if ([recorder prepareToRecord] == YES){
[recorder record];
我每次按下录制按钮都会释放并创建播放器。但问题是,AVAudiorecorder在开始记录之前需要一些时间,所以如果我连续多次按下记录按钮,我的应用程序会冻结一段时间。 当耳机连接到设备时,相同的代码工作正常,没有任何问题...录音没有延迟,即使我多次按下录音按钮,应用也不会冻结。
如果有人指导我纠正这个问题,会很有帮助。 在这方面的任何帮助将不胜感激。
Thanx提前。