0

嘿,我正在尝试按特定顺序播放多个音频文件,当我运行我的代码时,它会同时播放所有这些文件。我知道问题出在哪里,我只是不知道如何分隔每个文件。我正在使用 xcode 4.3

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

1 回答 1

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++;
}
于 2013-08-11T19:07:49.473 回答