My app will utilize 10,860 mp3 files. Is it feasible to drag these into the project or should they be linked from another location?
Thanks!
My app will utilize 10,860 mp3 files. Is it feasible to drag these into the project or should they be linked from another location?
Thanks!
I would definitely not do that. Put them in a folder next to your project. You could use build automation to copy them into your app’s resources on each run, but that’s only a good idea for building, not debugging. You don’t want to be copying all those files every run. Instead, in debug mode, get the files from the location next to your project.
A function like this will help:
Function GetAudioFile(Filename As String) As FolderItem
#if DebugBuild
Return New FolderItem("Audio Files").Child(Filename)
#else
Return SpecialFolder.Resources.Child("Audio Files").Child(Filename)
#endif
End Function
Use a build step to copy them into the Resources folder then in code reference them using SpecialFolder.Resources.
Thanks for the reply! To make sure I’m understanding correctly:
The method will take one parameter called “filename” As String.
The method Return Type should be FolderItem
The mp3s are going into a folder next to my project called “Audio Files.”
Is that correct?
In my example code, yes. You are of course welcome to change anything about that, it’s merely an inspiration point. I did no error checking, for example. You could rename the folder, or even change the return type so that it opens the file into a sound object instead.
Understood. I was just following your naming conventions for clarity’s sake. Thanks very much!
Personally, I would keep them on a web server somewhere with a SQL database of all their http locations. As you need an MP3, check if it’s local in your ApplicationData > “Audio Files” folder and, if it is then play it. If it is not, then download it from your server using a URLConnection (it’s trivial), place it in your ApplicationData > “Audio Files” folder then play it.
You might also want to check the MP3 Modification dates or file sizes with the database and download the newer copy, in case it has been updated.
Why do this?
And how many times this will takes to be loaded (in David example, in Copy files on the first run).
Unles these are just some seconds samples.
You do not disclose this important information.
You are correct! My bad. I will correct that oversight.
10,860 10MB files is 108.6GB…
Even if these are 1MB files, that’s 10GB.
I would definitely put these on a CDN and download on demand unless absolutely certain that all the files will be needed by all users.
As Emile pointed out, I neglected to mention how big the mp3 files are. They aren’t big at all. About 4 KB each. Does that mitigate the problem of app size enough to render it moot?
If it’s still an issue, I’ll probably go with your suggestion 5.
That’s about 44MB total. I’m on the fence. If you want to store them in the app, I wouldn’t fault you for it. One thing to consider though is download bandwidth. Essentially every user is getting every file with every download. Is that necessary? It may still make sense to download on demand so that you only pay for download bandwidth that users actually need. But 44MB is small enough that either way would be acceptable I think.
I meant to thank you for your input as well. I had to looked up what build step is all about. From what I read, my understanding is that I wouldn’t implement that until I’m ready to deploy the app. Is that correct?
I would say… load 10 files using build script (fast enough to not wait) during the debug time and when you are ready to deploy, load the whole package with build script to be sure everything is OK. But I think it will takes seconds (less than 10) and since at one time you will have to do that, check when you have the time (but quickly) and decide by yourself.
Do the same for the App icon (this time it is the project load time that will be faster if you use a build script (no need to save it each time you save the project. IMHO
Store them externally to the project and load them at runtime. After all, there’s no way you are referencing the specific names of over 10K audio files in code - you must be referring to then via some indexing scheme.
If they are critical to the app - ie the app does not run, or doesn’t function correctly/make sense without them - then I suggest you simply include them in your app’s bundle so that they are downloaded by the user when they acquire the app. 44MB just isn’t much compared to the likely size of the rest of your app and it will save you a lot of coding, infrastructure, and maintenance to avoid implementing a delayed download system.
Is it necessary for every user to get every file? Yes and no. No, in that few users if any will use every file. Yes, in that it’s impossible to know which files any given user will require at any given time.
There are approximately 300 files that the vast majority of users will require. The rest could probably be downloaded on demand.
At 44mb, I would bundle them. At the size of everything these days, 44mb is nothing. To me, the worst experience is opening an app to find out it needs to download more things before I can begin using it.
Same here, but I found worst in the Windows world: you download a… downloader application !
Time to upgrade from Win 98SE
My thinking exactly. The last thing I want is for the end user to find him/herself at the mercy of an internet connection.
Thanks!