2013-03-11 80 views
0

嘿,我試圖以特定的順序播放多個音頻文件,當我運行我的代碼時,它一次播放所有音頻文件。我知道問題出在哪裏,我無法弄清楚如何分離每個文件。我使用的Xcode 4.3在一個訂單中播放多個音頻文件Xcode 4.3

[callSignPlayer play]; 
[VFRPlayer play]; 
[airportPlayer play]; 
[weRAPlayer play]; 
[aircraftPlayer play]; 

回答

0
我發現這是創建一個循環,移動到下一個音頻文件作爲......看到這裏

for (int soundsIn=0; soundsIn < totalSoundsInQueue;) { 

    NSString *sound = [theSoundArray objectAtIndex:soundsIn]; 
    while(![Player isPlaying]){ 

     Player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:sound ofType:@"caf"]] error:nil]; 


     [Player setVolume:1.0f]; 
     [Player play]; 
     //Increment for loop counter & move onto next iteration 
     soundsIn++; 
} 

最好的方法