2011-07-15 68 views
0

我正在實施AudioToolbox框架以嘗試播放音效。這裏是我的代碼: 我宣佈了一個名爲SystemSoundID爆炸音效不播放

NSURL *explodeURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]       pathForResource:@"Explosion" ofType:@"wav"]]; 
AudioServicesCreateSystemSoundID((__bridge CFURLRef) 
           explodeURL, explode);  
    [self performSelector:@selector(playsfx) withObject:nil afterDelay:2.0]; 

-(void)playsfx { 

    AudioServicesPlaySystemSoundID(explode) 
     } 

但由於某些原因的聲音從來不玩。

回答

0

你打電話AudioServicesCreateSystemSoundID,它不發聲,只是爲它創建一個ID。使用AudioServicesPlaySystemSound(explode);

+0

即時對不起,我複製了錯誤的代碼我已經使用audioservicesplaysystemsoundid我只是複製它錯對不起 – user842059

+0

啊,在這種情況下,我不知道。如果您嘗試AudioServicesPlaySystemSound(爆炸)會發生什麼;在創建系統聲音後立即? – Luke

+0

生病檢查,不,它不工作 – user842059