2013-03-01 53 views
0

(繼續我想說我開發的在VMWare下的Mac OSX,所以如果有人知道它可能是一個VM問題之前,請回答關於反正那)EXC_BAD_ACCESS有聲音在cocos2d

我下面的cocos2d的一個簡單的教程,我趕到的聲音

這是我使用音頻

進口代碼:

// Import the interfaces 
#import "HelloWorldLayer.h" 
#import "SimpleAudioEngine.h" 

// Needed to obtain the Navigation Controller 
#import "AppDelegate.h" 

Init方法:

-(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) 

我怎樣才能使它發揮作用?

+1

您是否在實際設備上或僅在模擬器上試過這個?你可以毫無問題地演奏其他聲音嗎? – dqhendricks 2013-03-01 21:07:41

+0

在兩者上我都遇到同樣的問題。我不知道我錯在哪裏,因爲在教程中,我看到這個人也是這樣做的。 – user1714647 2013-03-01 21:30:52

+0

你有沒有嘗試過不同的MP3(最好是一個確認可以工作,即從另一個遊戲的應用程序包)? – LearnCocos2D 2013-03-01 22:23:13

回答

0

經過一番小小的挖掘,我看到了其他人也有這個問題。他們的問題是他們的系統中沒有安裝音頻驅動程序,因此根本沒有聲音播放,他們也收到了與您相同的錯誤。

http://www.cocos2d-iphone.org/forum/topic/13970

將是奇怪,如果這也是一個實際設備上發生的,雖然。你在PC上測試什麼設備?

+0

問題可能會出現,我也安裝了VMWare工具,但音頻驅動程序未安裝似乎很奇怪。我會做一些嘗試並回復你。如果您瞭解其他可能的信息,請儘快回覆。 – user1714647 2013-03-02 12:31:14

+0

無論如何,我也嘗試與iPhone 4s – user1714647 2013-03-02 22:46:30