开发者

(iphone) how to play sound sequentially with AVAudioPlayer?

开发者 https://www.devze.com 2023-03-09 04:54 出处:网络
I\'d like to play multiple sound sequentially. The sound data will be available via NSData. (to be more precise, I\'m going to play different sound whenever scrollViewDidEndScrolling is called, and st

I'd like to play multiple sound sequentially.

The sound data will be available via NSData.

(to be more precise, I'm going to play different sound whenever scrollViewDidEndScrolling is called, and stop previous sound if it is still playing)

Do I need to alloc/init AVAudioPlayer for every sequential sound?

If alloc/init/release AVAudioPlayer is开发者_开发问答n't a big deal, I could do that but I'm not sure


If using the higher-level AVAudioPlayer, then yes, you'd need to instantiate (alloc/init) an AVAudioPlayer for each.

Yet, the "expensive" part (time-wise) is prepareToPlay - which you could call in a separate thread, thus hopefully by the time you come to play any given sound, it will be fully ready to play.

0

精彩评论

暂无评论...
验证码 换一张
取 消