【发布时间】:2013-02-05 21:06:59
【问题描述】:
我正在用 cocos2d 2 构建一个 iOS 应用,我正在使用 SimpleAudioEngine 来播放一些效果。
有没有办法在前一个声音完成后对多个声音进行排序?
例如在我的代码中:
[[SimpleAudioEngine sharedEngine] playEffect:@"yay.wav"];
[[SimpleAudioEngine sharedEngine] playEffect:@"youDidIt.wav"];
运行此代码时,yay.wav 和 youDidIt.wav 会同时播放,相互重叠。
我希望 yay.wav 播放,完成后,youDidIt.wav 播放。
如果不使用 SimpleAudioEngine,是否有使用 AudioToolbox 或其他方式的方法?
谢谢!
== 更新 ==
我想我将使用 AVFoundation 来使用这种方法:
AVPlayerItem *sound1 = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"yay" ofType:@"wav"]]];
AVPlayerItem *sound2 = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"YouDidIt" ofType:@"wav"]]];
AVQueuePlayer *player = [[AVQueuePlayer alloc] initWithItems: [NSArray arrayWithObjects:sound1, sound2, nil]];
[player play];
【问题讨论】:
-
已编辑:找到一个当前有效的方法。
标签: ios audio simpleaudioengine