4

I want to create a package with multiple directories containing media data (audio and video) which I then load as AVURLAssets.
As AVURLAssets are created with an URL, I can't use (as far as I know) NSFileWrapper. The documentation states that NSFileWrapper stores the complete content of the file in-memory, which doesn't seem like a good idea with maybe up to one GB of video data.

I'm currently using writeToURL and readFromURL to read/write the package, but this doesn't work as expected as the URL is a temporary directory and the whole process fails if this directory is empty (which happens if nothing has changed).

In addition, as I download the audio/video files, it would be even better to store it in the package as soon as it's completely loaded (not only when autosaving/saving). I know I could use the Cache or Application Support folder for this, but I'm not completely sure what happens to the Application Support folder when the app is uninstalled (worst case a user has multiple GBs of unnecessary data on his hard drive). The documentation states that an app shouldn't rely on files in the cache directory, but I need the media files somewhere on the disk for fast/offline access.

What would be the correct way to handle this scenario?

thomasguenzel
  • 670
  • 7
  • 25

0 Answers0