简体   繁体   中英

How do I merge audio files from my website to my iOS App?

I have a website that has some audio files that I will be constantly updating overtime. I am creating an iOS App for this website. What is the best practice for this type of work so I am not having to update the audio files for the app and the website differently?

  1. Would I need to create a Web API that pulls the audio files from my website to my app?
  2. Would it be better to store the audio files in a database and have the website and iOS app pull from the database?

If either one of these are better I would like to be pointed in the right direction to learn how to do this. Any tips would be great.

I have researched online, but can't seem to find the right answer to this type of challenge. The code for the website is very simple and written in html and css.

Here's a brief outline of what you need to do:

  • Create server API to get URLs to audio files
  • Use API from iOS application
  • Store audio files data (like url and params) but not files itself to local database
  • Download files to User document directory (or Caches directory, whichever make more sense in your case)
  • On next next app launch, check API again
  • Compare API answer with you local DB data
  • Delete files from document directory that no longer needed
  • Store new data to local DB
  • Download new audio files that weren't there before
  • Rinse and repeat

Related docs:

  • Network requests
  • Realm - Easiest database to pick for Swift iOS project
  • File System - check Where You Should Put Your App's Files section, read everything too, at least briefly
  • FileManager - easy to use class to store files

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