Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVAudioPlayer Error using iOS Simulator

following problem:

<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'

I found this problem already here on stackoverflow but none of the provided solutions worked for me.

Code:

#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

Delegate is set. Dont know if its important but on another mac this code runs without problems.

I use ios 6.1 and simulator 6.1

like image 386
Mulgard Avatar asked Jun 26 '13 11:06

Mulgard


1 Answers

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:

  • Input: Internal Microphone
  • Output: Internal Speakers

Hope this helps. My code is very similar to yours, and I don't think this is a problem with your code at all.

like image 53
Paul Sanwald Avatar answered Dec 11 '22 09:12

Paul Sanwald