嘿所有我正在尝试按特定顺序播放多个音频文件,当我运行我的代码时,它会立即播放所有这些文件。我知道问题出在哪里我无法弄清楚如何分离每个文件。我正在使用xcode 4.3
[callSignPlayer play];
[VFRPlayer play];
[airportPlayer play];
[weRAPlayer play];
[aircraftPlayer play];
答案 0 :(得分: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++;
}