AVAudioPlayer使用iOS模拟器时出错

Mul*_*ard 5 runtime-error avaudioplayer 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'
Run Code Online (Sandbox Code Playgroud)

我在stackoverflow上已经发现了这个问题,但是所提供的解决方案都没有为我工作.

码:

#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
Run Code Online (Sandbox Code Playgroud)

代表已设置.不知道它是否重要但在另一个mac上这个代码运行没有问题.

我使用ios 6.1和模拟器6.1

Pau*_*ald 16

我有同样的问题,并能够通过调整我正在运行模拟器的mac上的声音设置来修复它,根据这个问题的答案.我正在使用外部声卡,并通过以下方式更改我的mac上的音频设置就可以了:

  • 输入:内置麦克风
  • 输出:内置扬声器

希望这可以帮助.我的代码与您的代码非常相似,我认为这根本不是代码的问题.