adam-codersgu / supernova

A Kotlin-based Android application that allows the user to play music from their device while custom animations fall over the album artwork of the currently playing song.
0 stars 0 forks source link

Enhanced library maintenance approach - monitor media store directly #9

Closed adam-codersgu closed 1 year ago

adam-codersgu commented 1 year ago

Currently, the user's music library is refreshed whenever they open or return to the app. It would be preferable (and potentially less code intensive) to instead monitor the media store directly via some form of observer. I believe this is possible. If such a feature can be implemented, then it would allow the music library to be updated in realtime

adam-codersgu commented 1 year ago

Working on branch feature/media_store_content_observer

adam-codersgu commented 1 year ago

Useful resources: Github with implementation: https://github.com/vegaasen/mediaSnuggler/blob/master/src/main/java/com/gtfo/snuggle/upnp/content/MediaStoreObservers.java Android doc: https://developer.android.com/reference/android/database/ContentObserver StackOverflow answer: https://stackoverflow.com/questions/12546967/android-how-to-detect-a-change-in-mediastore-when-connected-over-mtp

adam-codersgu commented 1 year ago

Need to test whether this observer detects deletions and insertions

adam-codersgu commented 1 year ago

Interesting addition for API 30 https://developer.android.com/reference/android/database/ContentObserver#onChange(boolean,%20java.util.Collection%3Candroid.net.Uri%3E,%20int)

adam-codersgu commented 1 year ago

Should have a system for preventing simultaneous requests to update the music library, but note that a new request was received and process it when ready

adam-codersgu commented 1 year ago

Implemented and merged https://github.com/adam-codersgu/supernova/pull/38