我使用AVAudioRecorder來記錄聲音,但我有一個問題。iphone:AVAudioRecorder記錄總是返回FALSE
調用方法[錄音機記錄]後,recorder.recording的值總是返回FALSE,讓我無法停止錄製。
我使用的XCode 4.2與iOS 5,我的iPad上的iOS 5還的iPad 2。
這是我的代碼:
self.currentFileName = [GlobalRecording newRecordingFileName];
NSURL *url = [NSURL fileURLWithPath:[[GlobalRecording recordingDirectory] stringByAppendingPathComponent:currentFileName]];
NSError *err = nil;
AVAudioRecorder *aRecorder = [[AVAudioRecorder alloc] initWithURL:url settings:recordingSettings error:&err];
if(err){
NSLog(@"could not create a recorder: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
return;
}
self.startRecordingTime = [NSDate date];
recordingLength = 0.0f;
// setup recorder and start recording
[aRecorder setDelegate:self];
aRecorder.meteringEnabled = YES;
[aRecorder record];
self.recorder = aRecorder;
BOOL test = recorder.recording;
[aRecorder release];
[aRecorder記錄]它是否是成功還是失敗,返回boolean值。你可以檢查你的記錄電話是否成功嗎? – Saran
[aRecorder record]的返回值爲FALSE。這意味着它不會成功。我的代碼錯了? – haisergeant
任何人都可以幫助我嗎? – haisergeant