gpt4 book ai didi

ios - iOS:模拟器中的音频录制设置失败,但我的设备上没有?

转载 作者:行者123 更新时间:2023-12-03 02:13:16 26 4
gpt4 key购买 nike

我正在我的应用程序中录制音频。
该应用程序可以在装有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];
}
}

它在控制台的最后一行带有(lldb)的 [recorder prepareToRecord]中失败

最佳答案

关于ios - iOS:模拟器中的音频录制设置失败,但我的设备上没有?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22359366/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com