Process for finding audio files - need to know!

Can a developer please post to this thread the process that the app uses to find the audio files on the device? And once it finds the files, is it able to record that information somewhere, so that next time the app starts, it doesn’t have to look for them again, or at least it looks there first? (I assume the app has a place to store settings, as there are app settings, current Bible reference, UI language, etc. that are all saved…)

Story time… Here’s the situation for one user. He has a fairly slow Android phone with a fairly large 64GB internal memory, with lots of lots of files (almost full), and he has a 32GB SD card which doesn’t have much on it. I copied the Bible audio (740Mb of .webm files for the whole Bible) to the SD card. I started the app, and tried to play the audio, but it just turned and turned for a very long time. However, I think there might also be something wrong with the SD card, as sometimes the audio folder seemed to just disappear(!). So after a couple of times trying to work with the SD card, I got rid of the audio off of the SD card and copied just a few chapters of the audio into the internal memory. Restarting the app, playing the audio, still it turned and turned. I tried various things, but never got it to play. I turned my attention to other things, but apparently before doing that I had pressed play and it was turning and turning, because after a significant time (it must have been at least a few minutes), the audio started playing! So anyway, for this user, I’ve asked him to clean off his SD card and we will try to reformat it, and also to clean some space off of the internal memory. I think the latter is where he wants to store the audio files, so that they are stable, and not subject to SD card caprices.

Bottom line… If the app can store the audio location once it finds it and reuse that information, then I think it is probably acceptable to take a long time the first time.

But this particular app is an app where the audio for OT and NT comes from two different repositories, so we gave two different folder names in the audio file sources in SAB: Bible-NT-Arabe-SHU-Audio and Bible-OT-Arabe-SHU-Audio. However, from our testing, it seemed like just putting all of the audio files in one folder called Bible-Arabe-SHU-Audio was working well, and it made it easier for the audio folder to be shared with other users. So that is how we normally set it up on people’s devices, with just the one folder. But now I’m wondering if because this unified audio folder does NOT have the same name as the file sources in SAB, that that first time that it looks for the audio, it doesn’t find it quickly because it looks through all of the folders for those two folder names (and it doesn’t find either the NT or the OT version), and then it has to look through each individual file on the device for the exact file name for that chapter.

BUT I’m wondering if we put Bible-Arabe-SHU-Audio (the unified folder name) in the “Download to Folder” for both of the audio file sources (both the OT and NT repositories) in SAB, will that help the app find our one large audio files folder (with that exact name) faster? That would be a simple change in SAB, and could be posted to Play Store fairly quickly, if that could help.

If we did that, and the user downloaded audio files from FCBH Bible Brain, then both the OT and NT files would just get downloaded and mixed together in the same download folder, but that shouldn’t be a problem since there is no overlap of file names.

A somewhat related question… When the app downloads audio files, where is it supposed to put them? Because I did some audio download testing on a pretty bad Internet connection, and sometimes the app said that it failed, so I tried again, and sometimes, even after the failure message comes up, a bit later my phone would say that it is downloading something (flashing download icon in the bar at the top), and sure enough, later on I would be able to play that audio that I had been trying to download, but that the app said had failed to download! Sometimes I would even end up with multiple copies of one audio file (name-1, name-2, etc.). But in these various tests, I saw audio downloads going into two different places. One was the Movies folder (I assume since .webm files are actually a video format), in a subfolder with the name of the app, and I think the audio files were right under that. The other place I saw the audio files appear was Phone/Android/data/org.ipsapps.chad.shu.bible.latn/files and I think it created a sub-folder with the audio source folder, e.g. Bible-OT-Arabe-SHU-Audio, and put the audio files in there. My guess would be that the ones that the latter (in the Android/data folder) are ones where the app succeeded in downloading and put them there intentionally, and the ones in Movies folder were ones where the system took over the download when the app thought it had failed and managed to complete the download but then didn’t know where to put the file (so it put it in Movies, in a folder with the requesting app’s name). Does that make sense? Should the audio download timeout in the app be increased (it was pretty quick to declare an error)? Should the app kill any audio download process if it determines failure, so we don’t have audio files going other places?

The reason we need to know the answers to the questions in the first paragraph is that if there are some downloaded audio files (maybe in two places), but also an audio file folder, how does the app know where to go to find the audio files? Does it somehow need to do some clean-up to remove duplicates?

Thanks for listening… :slight_smile:

Some of the details of what happens will be changing soon with the addition of a ‘Downloads Manager’ - which will record the location of audio files it finds.

But in brief, if you are using Android 10 and above, the files are downloaded temporarily to an internal data folder specific to your app, then they are copied to a sub-folder of one of the common Media Store folders: “Music” for mp3 files or “Movies” for webm or mp4 files.

Thanks @richard for the information about downloads, and the upcoming Manager. That’s encouraging.

But you didn’t mention how the app actually looks for the files. Would putting the audio files in a folder with a name that is exactly the same as the “download to” folder in the SAB settings allow the app to find the audio files faster?

If so, I think changing our app so that the Audio File Source “Download to Folder” for both the OT and NT repositories is defined as “Bible-Arabe-SHU-Audio” would be beneficial.

For Android 9/10 and above, it’s best to put the files in the “Music” (for mp3) or “Movies” (for webm) folders - or sub-folders of these folders. Then they are indexed in the Android Media store and can be found quickly.

Excellent information! Thank you for that, @richard!

I assume putting the folder with the .webm files as a sub-folder of Movies on an SD card would be equally helpful?