使用iOS模拟器的AVAudioPlayer错误

编程入门 行业动态 更新时间:2024-10-28 10:21:54
本文介绍了使用iOS模拟器的AVAudioPlayer错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

以下问题:

<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

推荐答案

我遇到了同样的问题,并且能够根据此问题的答案.我使用的是外部声卡,并且通过以下方式更改了Mac上的音频设置就可以了:

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错误

本文发布于:2023-11-26 16:04:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634338.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模拟器   错误   iOS   AVAudioPlayer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!