使用iOS模拟器的AVAudioPlayer错误 [英] AVAudioPlayer Error using iOS Simulator
问题描述
以下问题:
<0xb03e7000> Error '!obj' trying to fetch default input device's sample rate
<0xb03e7000> Error getting audio input device sample rate: '!obj'
<0xb03e7000> AQMEIOManager::FindIOUnit: error '!dev'
我已经在stackoverflow上找到了这个问题,但是没有一个 提供的解决方案对我有用.
I found this problem already here on stackoverflow but none of the provided solutions worked for me.
代码:
#import "CJTActionViewController.h"
@interface CJTActionViewController()
@property NSURL *url;
@property NSData *songFile;
@property AVAudioPlayer *audioPlayer;
@end
@implementation CJTActionViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.url = [NSURL fileURLWithPath: [NSString stringWithFormat:@"%@/cannon_01.wav", [[NSBundle mainBundle] resourcePath]]];
self.songFile = [[NSData alloc] initWithContentsOfURL:self.url];
self.audioPlayer = [[AVAudioPlayer alloc] initWithData:self.songFile error:nil];
self.audioPlayer.delegate = self;
self.audioPlayer.numberOfLoops = 0;
}
- (IBAction)firePressed(id):sender
{
[self.audioPlayer play];
}
@end
代表已设置.不知道它是否重要,但是在另一台Mac上 代码运行没有问题.
Delegate is set. Dont know if its important but on another mac this code runs without problems.
我使用ios 6.1和模拟器6.1
I use ios 6.1 and simulator 6.1
推荐答案
I had this same problem, and was able to fix it by adjusting the sound settings on the mac I am running the simulator on, per the answer to this question. I was using an external sound card, and changing the audio settings on my mac in the following way did the trick:
- 输入:内置麦克风
- 输出:内部发言人
希望这会有所帮助.我的代码与您的代码非常相似,我完全认为这与您的代码无关.
Hope this helps. My code is very similar to yours, and I don't think this is a problem with your code at all.
这篇关于使用iOS模拟器的AVAudioPlayer错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!