简体   繁体   中英

(iphone) how to play sound sequentially with AVAudioPlayer?

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 isn'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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM