Fixing delay starting playback of AVAudioPlayer on iOS

Here’s a discussion on StackOverflow about how to fix the “stutter” or “slow start” playing back a sound on iOS using AVAudioPlayer:

Basically there are two recommendations – preflight the player by playing a very short “silent” sound (on another thread), or calling [audioPlayer prepareToPlay].

It seems like the main cause of the hiccough when first playing audio is firing up the audio hardware and allocating playback buffers. Apple’s documentation seems to confirm this between the lines.

See AVAudioPlayer Class Reference

Be First to Comment

Post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.