0

I'm developing an app which has about 500 different short audio sounds, each has its own mp3 file. I'm using AVAudioPlayer to play them. The audios shouldn't be play simultaneously.

I thought of several options:

  1. Initializing 500 AVAudioPlayers objects, and when necessary call play() for the relevant object
  2. Holding 1 AVAudioPlayer, and change it to point to the relevant file as necessary. this require files name management that consumes 500 Strings and in runtime to initialize its resource path for reinitialization. (may be harder to debug)
  3. Holding 500 paths to resources (semi resource initialization) and 1 AVAudioPlayer that serves them all

What is the best practice for it?

hoshmy
  • 61
  • 4

1 Answers1

1

Option 1 is a bad idea, and will use GOBS of memory. It may even cause your app to be terminated due to using too much RAM.

Solutions 2 and 3 are practically identical.

Duncan C
  • 128,072
  • 22
  • 173
  • 272