3

As is demonstrated in this answer, I have recently learned how to play audio files using both AVAudioPlayer and AudioToolbox. I have successfully played a single audio test file using both methods. However, I want to ask about which one I should actually use in my app (or if it even matters).

Here are the relevant characteristics of my app:

  • There are about 800 audio clips.
  • Most of the clips last less than one second.
  • Any could be chosen to be played at random by the user, but only a small subset will be used on any particular run.
  • No special volume control or playback options are needed.

These are my questions:

  • Which method for playing a sound would be better? Why?
  • Should I preload the sounds or just load them when they are needed? I'm guessing that preloading 800 sounds every time is a bad idea. But if I wait to load them until they are needed, I am worried about performance (ie, a noticeable pause before the clip is played)
  • Do I need to play sounds on a background thread?

So my concerns in choosing which audio player to go with are memory and performance. I couldn't tell from any of the documentation that I saw which is better in this case.

Community
  • 1
  • 1
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393

0 Answers0