Je suis en train d'enregistrer en utilisant le microphone iphones: Ceci est mon code:L'opération n'a pas pu être terminée. AVAudioRecorder SDK iPhone
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// the path to write file
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"testing.mp3"];
NSURL *url = [NSURL fileURLWithPath:appFile isDirectory:NO];
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatMPEGLayer3], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityLow], AVEncoderAudioQualityKey,
nil];
NSError *error;
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];
if ([recorder prepareToRecord] == YES){
[recorder record];
}else {
int errorCode = CFSwapInt32HostToBig ([error code]);
NSLog(@"Error: %@ [%4.4s])" , [error localizedDescription], (char*)&errorCode);
}
NSLog(@"BOOL = %d", (int)recorder.recording);
Ceci est l'erreur que je reçois:
Operation could not be completed. (OSStatus error 1718449215.)
Et je ne peux pas comprendre pourquoi ce doesn ne fonctionne pas, comme beaucoup du code que j'ai reçu d'un site Web.
Jonathan
pour une raison quelconque, il ne s'initialise pas. En faisant 'if (enregistreur) {NSLog: @" Oui "; } 'n'écrit pas oui dans le journal. –