【发布时间】:2013-03-01 20:39:49
【问题描述】:
(在继续之前,我想说我是在 VMWare 下的 Mac OSX 上开发的,所以如果有人知道这是否可能是 VM 问题,请无论如何回答)
我正在学习 cocos2d 的一个简单教程,我到达了声音
这是我用于音频的代码
进口:
// Import the interfaces
#import "HelloWorldLayer.h"
#import "SimpleAudioEngine.h"
// Needed to obtain the Navigation Controller
#import "AppDelegate.h"
初始化方法:
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super's" return value
if( (self=[super init]) )
{
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"Field1.mp3" loop:YES];
CCMenuItemImage *uno = [CCMenuItemImage itemWithNormalImage:@"vblue.png" selectedImage:@"vblue.png" target:self selector:@selector(uno)];
uno.position = ccp(-150,0);
CCMenuItemImage *due = [CCMenuItemImage itemWithNormalImage:@"vgreen.png" selectedImage:@"vgreen.png" target:self selector:@selector(uno)];
due.position = ccp(-50,0);
CCMenuItemImage *start = [CCMenuItemImage itemWithNormalImage:@"play.png" selectedImage:@"play.png" target:self selector:@selector(uno)];
start.position = ccp(150,0);
CCMenuItemImage *stop = [CCMenuItemImage itemWithNormalImage:@"pausa.png" selectedImage:@"pausa.png" target:self selector:@selector(uno)];
stop.position = ccp(50,0);
CCMenu *menu = [CCMenu menuWithItems:uno,due,start,stop, nil];
[self addChild:menu];
}
return self;
}
有问题的行是
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"Field1.mp3" loop:YES];
由于 Xcode 报告了音频错误,并且没有该行,游戏可以正常工作。
编译器输出:
<AudioControl> Error '!obj' trying to fetch default input device's sample rate
2013-03-01 12:29:09.101 Tutorial10[374:4803]
<AudioControl> Error getting audio input device sample rate: '!obj'2013-03-01 12:29:09.102 Tutorial10[374:4803]
<AudioControl> AQMEIOManager::FindIOUnit: error 'NoHW'
2013-03-01 12:29:09.104 Tutorial10[374:1b03]
<0xb0115000> AQMEIOManager::FindIOUnit: error 'NoHW'
(lldb)
我怎样才能让它工作?
【问题讨论】:
-
您是在实际设备上尝试过,还是只在模拟器上尝试过?你可以毫无问题地播放其他声音吗?
-
在两者上,我都遇到了同样的问题。我不知道我哪里出错了,因为在教程中我看到这个人也是这样做的......
-
您是否尝试过其他 MP3(最好是已确认可以使用的 MP3,即来自另一个游戏的应用程序包)?
-
是的,我也尝试过使用 .mp3 和 .wav,但它还是会崩溃。我不知道为什么
标签: ios objective-c cocos2d-iphone