我正在我的应用中录制音频。 该应用程序在iOS 5的iPhone 5C中运行就好了,但在模拟器中失败了(iPhone Retina 3,5英寸/ 4英寸/ 4英寸64位)
以下是设置音频的代码:
-(void)setupAudio{
_audioMessageLabel.text = @"...Bereit für Aufnahme...";
[_stopButton setEnabled:NO];
[_playButton setEnabled:NO];
// Set the audio file
NSString *guid = [[NSUUID new] UUIDString];
_dateiName = [NSString stringWithFormat:@"audio-notiz-%@.m4a", guid];
NSLog(@"dateiName: %@", _dateiName);
NSArray *pathComponents = [NSArray arrayWithObjects:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject],
_dateiName,
nil];
_outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
// Setup audio session
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
// Define the recorder setting
NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
// Initiate and prepare the recorder
NSError *error = nil;
recorder = [[AVAudioRecorder alloc] initWithURL:_outputFileURL settings:recordSetting error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
recorder.delegate = self;
recorder.meteringEnabled = YES;
[recorder prepareToRecord];
}
}
在控制台中使用(lldb)的最后一行[recorder prepareToRecord]
失败