Advertise here

Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

AVAudioRecorder [recorder record] always return NO

haisergeanthaisergeant Posts: 1New Users
edited December 2011 in Mac OS X Development
I have a problem with recording functionality of my application:

Recording directory is: /Document/Recordings/

[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]);

[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.


  • tgwootgwoo Posts: 1New Users
    I'm meeting the same problem. Finally I find "allow microphone access" in sandbox entitlements is not checked.
Sign In or Register to comment.