• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Software developer seeks opinions on media storage

AM Bucky

Lurker
May 20, 2023
8
1
Okay, so I'm not a ”software developer”, I just program as a hobby. But I'm currently developing my own media player. I'm using AppGameKit by The Game Creators and I believe I'm running Android 11 for anyone that finds that information relevant. My player is designed to find, load, and play audio files in a certain given directory.

This given directory, the basic ”Music” folder that automatically appears in the internal phone's memory, will have folders inside it that contain audio files. My app is designed to delve into that Music directory and identify/count/read all subfolders/files regardless of their names. My app works as I have programmed it to.

HOWEVER: If any changes are made to any of those files or folders then my app cannot detect them and the whole app fails... ... ... for a period of time. The kind of thing I'm running into is that my app is designed to be versatile in reading that directory, but if a folder is added or taken away, or if one of the files are renamed, then the app crashes. But if I put the phone down, or better yet go to sleep for the night, then I'll pick it up in the morning and the app will run fine again with the new folders/files. Without me actually changing anything with the phone or the app.

So my question is this (assuming my choice of software isn't the issue): is anyone familiar with maybe a service or app that Android runs in the background that keeps a record of the system's directory tree that updates itself at certain intervals? Maybe my app depends on something like this that just isn't ”updating” when I need/expect it to. I've already tried clearing the media system app and restarting the phone. All it did was reset my ringtone. And I tried clearing the cache on my own app, but it doesn't seem to help. It's just so bizarre to me that everytime I introduce new files to my app it crashes only to be fine an hour or whatever later. But any ideas would be appreciated. Thanks.
 
I moved your thread to the Dev area for better assistance. @AM Bucky
I use an old copy of Winamp. It only loads folders and sub folders that you choose. If files are added they are simply not listed to be played. Changing names or tree structure makes the files not found to be played. There is no update over time unless you let the app read the folders again. It does have a utility to run that will load a list of missing files such as name or location changes. Maybe you could write such a utility into your app. I'm not a programmer. I only mention the old app I use because it sounds like it works much the same as yours.
 
  • Like
Reactions: mikedt and ocnbrze
Upvote 0
Screenshot_20230520_204426_Chrome.jpg
 
  • Like
Reactions: mikedt
Upvote 0
Hmm... (Thinking about the other part of your response)... You might be onto something there... I still think it has something to do with the Android system itself as opposed to the app I wrote, but perhaps I could add a step that compares a possible new file tree to a documented old file tree before it actually takes action. Or something... I'll think on that!
 
  • Like
Reactions: olbriar
Upvote 0
I'm not a dev so probably can't assist you much. But FWIW I use the Foobar2000 audio player, and I think it works similar to your media player, in it's designed to find, load, and play audio files in a certain given directory. And if any changes are made, like say a given directory is deleted or a new one with MP3s is added. Foobar does register the change while it's running, However it has to be refreshed, by going back to the root folder, and then to into the sub-folder list., and then the changes shows up in Fooobar's directory and song lists.
foobar2000.org

I'm pretty sure Foobar isn't using the Android system media scanner, as AFAIK that scans and indexes the entire internal storage and SD, and will add all media files to some music players, including ringtones and phone call recordings. Unless they've been specifically excluded with the .NOMEDIA file descriptors.
 
Last edited:
  • Like
Reactions: olbriar
Upvote 0
I'm pretty sure Foobar isn't using the Android system media scanner, as AFAIK that scans and indexes the entire internal storage and SD, and will add all media files to some music players, including ringtones and phone call recordings.
Forgive my ignorance, but what is ”AFAIK”?

And to give you guys a peek under the hood to explain how exactly my app works:
First off, have you ever hit the shuffle button on a media player, but the generated playlist just didn't look ”shuffled”? And also, have you ever had 1,500+ songs and was just spoiled for choice and didn't know what to play? Well that's what I'm here for! Because my media player takes your excessive catalogue of song files and simulates an FM radio! Only better than an FM because there are no commercial breaks and no annoying DJs that drone on and on! Inside the Music folder you place however many folders you like, but each of these folders will represent it's own ”station” if you will. Within each station you place however many folders you like, but each of these folders will represent a band that plays on that station. Within THESE folders you place as many songs from that band that will play on these stations.

Now my app has two functions: the reset and the play. You must reset before you play. But when you hit the reset, what happens is that the app scans all these folders and generates text files that contain playlists for each station that spread out the files to help make sure you get a decent variety of music. For example, let's say a station has 4 songs from Metallica, and 10 songs from Aerosmith. The generated playlist will look something like:

Aerosmith
Aerosmith
Metallica
Aerosmith
Aerosmith
Metallica
Aerosmith
Aerosmith
Metallica
Aerosmith
Aerosmith
Metallica
Aerosmith
Aerosmith

Even though you have much more Aerosmith, it tries to spread them out so you aren't bombarded with a single band. But again, you can have as many stations and bands within the stations as you want. (There's a whole mathematic formula I made to do it.)

So when you have the text documents that are generated by the reset, you can play the stations. The app goes down the list of stations and keeps track of where on the playlist it left off. It will begin the next song of all stations at the same time (because real radio stations don't wait for you to tune in to start their music). A button appears on screen for each station, and you will only hear the station that you are ”tuned” into. Meanwhile, whenever a song ends, the app just throws the song out of memory, references the playlist for the next one, loads it, plays it, and documents where on the playlist it's now at. All stations run whether you're listening to them or not... Just like a real radio station!

So yeah, it works by scanning directories and documenting them in text files and then later referencing those text files to create stations. It's just that anytime I want to add stations/songs I have to wait an hour until the phone says ”oh hey, I found these laying around!”
 
Upvote 0
It is possible that your app is relying on Android's MediaStore system in order to update and recognize new files or folders. The MediaStore is a system-level service that maintains an index of all media files such as audio, video, and images on the device. It also updates this metadata after changes are made to any of these files. If your app is indeed utilizing the MediaStore system, it may be that it is not automatically updating itself frequently enough for your needs. You could try running a MediaStore scanner manually from within your app to ensure that it is up to date with the latest files.
Tell me more. Is this the kind of system app/service I can manually stop, clear, and restart? Is it in the app list (once you tell it to display system apps)? If so, what is the actual name of it? (Is it just MediaStore or maybe like com.android.mediastore or something like that?) I seem to remember on older Androids there was an app called ”media storage” if I recall correctly, but on this phone all I saw was one called ”media”. And clearing it didn't help.

Or is it just something the operating system does from time to time and I just have to deal with it? I don't remember anything about MediaStore in the command library for my software, but I'll definitely check when I get home today. (For the record I consider myself a decent programmer, but I know very little about operating system level stuff.)
 
Upvote 0
Interesting... I don't think my software allows for that kind of check (I'll look into it though). The weird thing is: the programming language I'm using, if I understand correctly, is derivative of the BASIC language. The makers of the software originally intended it to be for 3D gaming on PCs but overhauled it to add the ability to make apps on Android. But to do that, you take your code and run it through a menu that ”adapts” it into Java... I don't think they added MediaStore functions.

But this is exactly the kind of answer I was looking for alberomorris. Thank you for your time. Is there any way to at least know when the MediaStore will recycle? If it was at least predictable it would make a world of difference...
 
Upvote 0
i think people can refer to Dropbox.com for storage. With a simple interface and convenient arrangement for users, Dropbox is considered one of the most useful cloud storage service applications available today. Dropbox supports large storage space, helping users automatically back up information if installed, or access documents without the network, ...
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones