简体   繁体   中英

Best way to manage a large number of files in iOS

I'm going to have a large number of mp3 files in my app. Right now, this is what I do:

  • Use On Demand Resources so that the files will not affect the app size;

  • At first launch:

    • If user is connected to WiFi, download all the files and store them in the app documents directory;
    • If user is not connected to WiFi, ask him to download or download later.

Now my question is:

If the total files size reaches more than 300mb for example, it will be a problem since maybe the user will delete the app because he is running out of space. How can I solve this?

I was thinking about:

  • store my files online and play, but then everytime the user wants to play them, he will use mobile data. Or, if the user doesn't have data connection or he is in a place without signal, he won't be able to use the app;

  • compress the files in a zip, then unzip it when the user wants to play them and zip again;

  • ask the user which files he wants to download, and then remove them if he wants to download more.

Without knowing how an average user will use the app it is impossible to say is it better to download everything, allow user to download only required files or store everything online. In general you should not make user wait or limit app functionality if user has slow connection.

One thing you should do for sure is to decrease files size as much as possible. Zip will not help you since it can not decrease already compressed media files (like mp3, ogg and others).

First off all check that audio bitrate is not too big. Typical bitrates for different purposes:

  • 32kbit/s: AM Radio quality
  • 48kbit/s: Common rate for long speech podcasts
  • 64kbit/s: Common rate for normal-length speech podcasts
  • 96kbit/s: FM Radio quality
  • 128kbit/s: Most common bit rate for MP3 music
  • 160kbit/s: Musicians or sensitive listeners prefer this to 128kbit/s
  • 192kbit/s: Digital radio broadcasting quality
  • 320kbit/s: Virtually indistinguishable from CDs
  • 500kbit/s-1,411kbit/s: Lossless audio encoding such as linear PCM

So if audio contains only speech 48 kbit/s is usually enough. For music 128 should be ok.

Second - you should use better compression codec than mp3. For detail information please check this link http://soundexpert.org/encoders-48-kbps but usually you should use AAC codec.

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