BimmerGestalt / AAIdrive

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

"Now Playing" button greyed out #124

Closed TBGR closed 3 years ago

TBGR commented 3 years ago

I have a NBT equpped BMW, the app identifies is as ID4++. I started using the app just before 1.2.2 was released and I could change songs using the button, even picking songs from Spotify playlists while having a free acount. It worked in YouTube Vanced playlists as well. Not sure if it was after I updated to 1.2.2 or a few days after it the button has become unavailable for me. Tested in Spotify, YouTube Vanced and Tidal with the same result. The app runs on an old S6 edge with stock ROM.

EDIT: Forgot to mention I have tried a few builds since then, will try downgrading to 1.2.1 and report back tomorrow.

hufman commented 3 years ago

Thank you for the very detailed report! This is very helpful, thank you :)

The Now Playing functionality should still be working, it depends on whether the music app provides the queue. I haven't tried Tidal or Youtube Vanced before, but Spotify (currently running the latest version) is still working for me. Youtube in general seems to have poor support for the Android Auto APIs (for some reason, haha) and I don't know how much extra functionality Youtube Vanced would implement in this area.

I do know there is misbehavior where the Spotify remote control API can refuse to control a modded Spotify app, is this a factor in your situation? You might try finding such a mod based on version 8.4.96.953, which doesn't require Spotify API access to gain full control, including queue functionality. One free app that has good queue support is the DSub Subsonic client, if you'd like to try it out.

I am interested to see what you find regarding 1.2.1. I can't think of any changes that would have affected the Now Playing queue feature, but I definitely want to figure out what's going on and how to fix it!

TBGR commented 3 years ago

Forgot to mention I tried with different Spotify versions as well. The one linked in the readme, a bit older one, and finally the one that some people said is the last properly showing up as the official app. Will revert to 1.2.1 in a few hours.

EDIT: Still not working with 1.2.1. Will try updating Spotify when I get back to the car.

TBGR commented 3 years ago

@hufman Just tried it with the release build of 1.2.2 and the linked Spotify apk, still no queue.

hufman commented 3 years ago

I greatly appreciate your patience and diligence in testing the combinations of versions!

I set up a testing free Spotify account and was able to reproduce this empty queue (which is what causes the greyed-out button) in the case where the AndroidAutoIdrive app was not granted control over Spotify through the official Spotify API.

Another symptom of this state is that the Spotify coverart does not reliably show up. Is this currently the case for you? If AndroidAutoIdrive has Notification Access, it gains control over any running music app. This allows for some basic control over Spotify, but only if it's running already. Any apps that are currently controllable show up on the internal Apps list in the car app, but only apps that can be launched from a stopped state will show up in the car's main Media Sources list. Does Spotify show up in the main list, or only in the internal list?

If you tap on the Spotify icon inside the AndroidAutoIdrive phone interface, it will bring up a little mini player. This attempts to connect to Spotify and should prompt for authorization if necessary. If that authorization goes wrong for any reason, the mini player will show a little (!) icon next to the title, and tapping that will bring up the error message. Is this icon present, and does it provide any additional information?

Please try out these steps and tell me if you find any additional information! I will try to incorporate these steps into the upcoming UI redesign to try to make it easier to figure out what's happening and how you can fix it.

TBGR commented 3 years ago

I can launch Spotify with no issues and it shows up as a source. Had some coverart related hiccups in 1.2.1, but no issues with 1.2.2. Will try building with an API key now. Also there is no ( ! ) in the interface. Just for good measure both Spotify and AndroidAutoIdrive have all permissions granted from the phone settings.

hufman commented 3 years ago

We merged a new feature yesterday that adds a Queue tab to the phone ui's mini player. Do you see a queue there from Spotify or your other apps with this latest version?

TBGR commented 3 years ago

Yep I saw it. On my main phone - an S10 it now works on Spotify, Had to relaunch the same playlist for it to appear though. On S6 edge that lives in the glove box with the sole purpose of runing Spotify it does not. Will fiddle around with it some more today.

Update: Tested it, the queue loads up after cleaning cache+data on the Spotify app. A few times it started a song not in the playlist, but that is probably due to the playlist being created by me with only 10 songs or so, and the others are suggested by Spotify due to it being a free account. Thanks @hufman and @Ben2356

hufman commented 3 years ago

Glad to hear that it's working for you! May I close this issue?

TBGR commented 3 years ago

Yep, although sometimes it starts the song under the one selected, but I could not recreate the bug and it has happened only 3 times so far.

hufman commented 3 years ago

Ah, I wonder if you are encountering a slight peculiarity with Spotify's MediaController queue implementation: It only updates the queue information whenever something browses its MediaBrowserService, which typically is only allowed for Android Auto itself. Perhaps this has been confounding the issue the entire time?

There's supposed to be a workaround in the app, to dispatch a background browse to trigger a queue update, but I have seen that same off-by-one bug before, even with the phoneui queue. I hadn't prioritized it because the Spotify API provides a richer coverart experience, and running the latest Spotify allows for this app to log in as Spotify to enable global coverart.

I believe the code currently prioritizes any MediaController queue over the Spotify API queue, because the Spotify API has a few queue bugs, but only the ancient Spotify version even shows this MediaController queue. You can tell which queue you are seeing: Spotify MediaController's queue starts at the currently-playing song and doesn't allow for going backwards, while Spotify API's queue will have cover art and (maybe, not sure about the free account behavior) will show the entire queue, allowing for back and forward navigation.

I'll try to look more closely into this off-by-one bug! It seems that the MediaController queue works slightly better for you than the API queue, and so I want to make it as perfect as it can be!

TBGR commented 3 years ago

Forgot to mention I have been running a premium account for the last few weeks. The issue happened once with the free and once with premium. Thanks again for looking into it.

TBGR commented 3 years ago

Both the issues have not popped up since I last commented, I suppose the issue should be closed.