BimmerGestalt / AAIdrive

Implementations of some Android Auto features as unofficial IDrive apps
MIT License
527 stars 89 forks source link

Music app: allow other music controls #65

Closed drm87 closed 4 years ago

drm87 commented 4 years ago

Unfortunatly, not all music apps allow full access via MediaController or MediaSession. But some, like Spotify, provide their own library/sdk for accessing these functions. It would be great to be able to use and implement such a custom interface for certain music apps.

I would suggest to define a interface with the functions used by the music app that such implementations could use. I would also try to implement it for spotify, but the interface should be clear first.

hufman commented 4 years ago

Here is Spotify's documentation I do wish they could use the official Android method to do this, but ah well! I can see the value for this request, it would fix the flaky cover art too I think.

hufman commented 4 years ago

I'm making good progress on this, and am now implementing Spotify to verify that I factored out a good interface.

drm87 commented 4 years ago

Great work, I already tried it out and it looked already quite good (at least in the app, it did not yet work in iDrive). The interface design seems also good and a good starting point for possible other integrations.

I would only suggest to use a different ContentType for browsing Spotify, as described here: https://github.com/spotify/android-sdk/issues/166#issuecomment-559412254 Using "default-cars" as the type value leads to far more reasonable results that are in line with those when using AndroidAuto.

hufman commented 4 years ago

I think this is complete in this branch, subject to further testing! I unfortunately haven't been able to go for any long test drives, which is why I haven't merged it yet.

drm87 commented 4 years ago

Alright, I will continue testing the branch with my car (although I am not driving that much in the current situation)

drm87 commented 4 years ago

So far it's working fine, but in commit bd9b89a496f6186540064395802686653ce33060 you removed the queue function for the Spotify controller. While it is true that their current API makes it quite cumbersome to access the current queue, your initial way to accessing the queue is still working for me. Only sometimes the queue is reported as empty by the API. But still, even in this case there seem to be no other bad effects. Is there any other reason you disabled the function?

hufman commented 4 years ago

Oh interesting, good catch! I disabled it because, on the old version of Spotify that I have installed, the code to fetch the tracklist from the context uri always received an empty list. I just tested, and the same code indeed works fine on an updated Spotify version. I've put the code back, and made a workaround so that the queue should work for both old and new versions.

Now, the only feature that the old Spotify MediaBrowserService holds over the new Spotify Remote SDK is Search support. The Spotify Remote SDK doesn't provide an API or access token to do web searches, currently.