I have a problem with recording functionality of my application:
Recording directory is: /Document/Recordings/
The problem is [aRecorder prepareToRecord] always return TRUE, that will create a record file in system (/Document/Recordings). But [aRecorder record], this method to begin recording, always return FALSE. That will make the record file is 0 byte, can not do anything with it.
I hope anyone have see this problem before and help me. Thanks.
Recording directory is: /Document/Recordings/
Code:
[recordingSettings setValue:[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
[recordingSettings setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordingSettings setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey];
[recordingSettings setValue:[NSNumber numberWithInt:AVAudioQualityMax] forKey:AVEncoderAudioQualityKey];
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;
}
[aRecorder setDelegate:self];
aRecorder.meteringEnabled = YES;
BOOL temp = [aRecorder prepareToRecord];
if (temp) {
NSLog(@"Prepare TRUE");
} else {
NSLog(@"Prepare FALSE");
}
temp = [aRecorder record];
if (temp) {
NSLog(@"Record TRUE");
} else {
NSLog(@"Record FALSE");
}
The problem is [aRecorder prepareToRecord] always return TRUE, that will create a record file in system (/Document/Recordings). But [aRecorder record], this method to begin recording, always return FALSE. That will make the record file is 0 byte, can not do anything with it.
I hope anyone have see this problem before and help me. Thanks.