【发布时间】:2014-03-12 17:29:33
【问题描述】:
我正在我的应用程序中录制音频。 该应用程序在我的带有 iOS 7 的 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];
}
}
在最后一行 [recorder prepareToRecord] 中失败,控制台中带有 (lldb)
【问题讨论】:
标签: ios iphone audio ios-simulator audio-recording