Skip to content
Advertisement

How to build an Android App with Media Playback from Spotify in 2021, without app remote?

I made a music player (Blade-Player) for Android, that can play music from local library, Spotify, and Deezer ; in 2018. I used the old Android Playback SDK from Spotify to achieve media playback.

As the code grew old, and Android/Spotify/… evolved, i could not maintain it the way i wanted, and it is now a collection of hacks and dirty stuff everywhere.

I’m trying to rewrite the whole thing, with cleaner libraries, using the new androidX compat library, RecyclerViews, Retrofit and GSon, that i didn’t even know existed at the time. So far i’m getting better performance indexing user library and a better UI, so this is great.

The problem is that now there is no Android Playback SDK from Spotify, as it is deprecated and no longer available. It still works in the old version of Blade-Player, so i could still use it, but i believe it is the source of multiple playback crashes and bugs, as it was written a long time ago (maybe it is a thread issue, or something, but Android thinks that Blade is crashing when the SpotifyPlayer is receiving data from the web, the player doesn’t work when used for a long time, …)

I tried to use the new App Remote SDK but, obviously, it isn’t adapted for a music player : all it does is start playback on the Spotify app, which is not what i want. If i have no other solution, i might settle for that, but then the point of having an unified music player for multiple sources disappears…

I discovered the Web Playback SDK on the Spotify dev website, but it doesn’t seem to be available for Android as is, and i don’t believe i can hack it to get an usable playback from my app.

I tried to “reverse-engineer” the old SDK, but all the Java code does is call native functions via JNI, functions that are in libspotify_sdk.so and other shared libraries. Even if i rewrote the Java part, i would still have to rely on that, which obviously seems to be the source of the current bugs. I could try to reverse-engineer the compiled ‘.so’ shared library, but i’m not sure to get any result.

(EDIT : I tried to look into it with Ghidra, but i don’t understand what is going on… playUri function only seems to perform checks and set up uri in some player globals, but then i don’t understand which function does the real playback, getting audio stream from uri…)

I don’t have any idea of what to do now. Because of the fact that the old SDK exists, i’m sure there is a way to get an encrypted stream or something from a Spotify track, but i don’t know how…

If you use Spotify in your app, how do you do it ? Did you find workarrounds for the old SDK, is it working fine ? Maybe just calling all of the old sdk functions inside a different thread or something ?

If you have any idea how i can include multimedia playback from Spotify in my app in 2021, without app remote, please let me know.

Advertisement

Answer

For the record, i solved that using librespot-java

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement