android / uamp

A sample audio app for Android
Apache License 2.0
13.06k stars 3.74k forks source link

Many issues with architecture #492

Open Sternbach-Software opened 1 year ago

Sternbach-Software commented 1 year ago

I would like to present a number of flaws in the UAMP architecture, and based on them, present an alternative architecture.

In the docs, it advises to use UAMP as the basis for a music player app. I found this to be an awkward task because of several architecture characteristics of UAMP:

Because of this (among other reasons), the already complex task of creating a media app was further complicated by having to "cut away" the extraneous parts of UAMP - the parts that do not contribute to the inherent functionality of a media player - as well as add the basic features that were missing (a process I am still arduously going through, with little success). On a first iteration, the extraneous code totaled approximately 800 lines of code. This was on top of the fact that I was trying to integrate player functionality to an already existing app, which meant removing the above-mentioned infrastructure code from UAMP, and implant UAMP in my existing app (it has not been a clean surgery). I turned to UAMP for this integration, because I knew that I could rely on UAMP to flawlessly implement the player functionality, so that I can have one less part of the app to worry about looking for bugs in. I was (and still am) hesitant to use an open-source player, because I can't be guaranteed that there likely won't be bugs from their implementation. Unfortunately, it is starting to look like using UAMP was the long shortcut.

It seems that UAMP falls in the no-man's land between a showcase app like Sunflower - which tries to be a full example of correct app architecture - and a codelab - which tries to be as bare-bones as possible, writing just enough to get across the point while still leaving you with reusable code at the end, and leave more advanced features for your curiosity in an alternative feature branch.

I would like to request a shift in architecture philosophy, from creating an app that people will copy and start writing their own app based on, to the more common codelabs-style barebones example. To date, (according to my results on Active Forks Finder) there are only 17 forks of this projects whose commits ahead of this project are non-zero (see table below), which seems to indicate that people are not deriving value from UAMP in the way that the docs suggest (viz. basing their media app on UAMP).

Besides for fixing the above issues, an actionable way to make it simpler is to remove the hierarchy of Albums -> List of albums -> List of songs -> Song NowPlayingFragment, and replace it with a predefined list of songs in a RecyclerView (they could be hardcoded or retrieved from an API, though the former would be more focused on music playing). The main activity would open up to that list of songs. This would remove the need for BrowseTree, all of the logic regarding isBrowsable, rootMediaId, the MediaItem abstraction, and probably all of the logic for navigation with LiveData<Event> (because there would only be two simple top-level destinations: list of songs and NowPlayingFragment).

I hope these issues appear cogent, and that my request for a change in architecture philosophy is considered. Given my use case, it would suit me more if the change happened in the direction of a codelab style, but if it took a step towards becoming more of a showcase app, I would be pleased all the same.

Forks with commits ahead

Link Name Stars Forks Open Issues Size Last Push Diff Behind Diff Ahead
Link lullabies-v3 1 2 22 318763 2021-05-27 -232 +133
Link android-UniversalMusicPlayer 1 1 1 11509 2022-08-02 -177 +23
Link android-UniversalMusicPlayer 1 2 0 7920 2017-09-30 -249 +11
Link android-UniversalMusicPlayer 39 8 0 6334 2015-08-19 -250 +5
Link android-UniversalMusicPlayer 41 9 0 7849 2018-04-01 -245 +4
Link xruamp 1 0 0 9581 2022-04-06 -3 +4
Link android-UniversalMusicPlayer 1 1 0 7746 2016-03-08 -250 +3
Link android-UniversalMusicPlayer 1 0 0 6868 2015-07-23 -250 +3
Link uamp 1 0 0 9159 2022-01-17 -6 +3
Link android-UniversalMusicPlayer 1 1 0 8813 2022-06-29 -250 +2
Link android-UniversalMusicPlayer 5 1 0 7836 2018-04-16 -245 +2
Link android-UniversalMusicPlayer 1 0 0 7794 2017-04-05 -250 +2
Link android-UniversalMusicPlayer 4 0 0 6893 2015-09-23 -250 +1
Link android-UniversalMusicPlayer 1 0 0 7735 2016-03-26 -250 +1
Link android-UniversalMusicPlayer 1 0 0 7765 2016-11-30 -250 +1
Link android-UniversalMusicPlayer 0 0 0 7830 2018-04-09 -245 +1
Link android-UniversalMusicPlayer 1 0 0 7840 2019-01-07 -237 +1
Link android-UniversalMusicPlayer 1 0 0 8214 2019-05-01 -177 +1