Open timusus opened 7 years ago
You need to have an interface defining basic "source" methods like "getSongs". Then, you create classes implementing this interface but with body adjusted to load the songs from different sources (MediaStore, Spotify, etc...). Also, your models (Song, Album, Artist, etc...) should have all the common meta data fields that you receive from any source type (song name, artist, album name...).
Take a look at my media player, how I implemented LocalMediaProvider, which extends MediaProvider interface. I can just make SpotifyMediaProvider, implement those methods to fetch data from Spotify instead of MediaStore and the rest should be pretty easy. And throughout the app you pass MediaProvider instances so it doesn't matter are the songs coming from your phone or another source.
Thanks @icarapovic, that's exactly the approach I had in mind.
This kind of ties in with the #13 (and depends on it). It would be the greatest thing ever to have support for pluggable sources, so I could begin working on, for example, a DLNA plugin, Google Drive plugin, Spotify plugin, or just whatever.