New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android Auto #578
base: redesign
Are you sure you want to change the base?
Android Auto #578
Conversation
This is awesome to see finally :) Is the 100 item limit just an awkward thing with Android Auto or a thing that specifically needs to be fixed here? Jellyfin luckily makes pagination very easy when fetching from the server. Artwork sounds like an annoying issue to fix though 🙃 |
I put that limit because someone reported Android Auto crashing on large libraries (1000+) I do have an idea on how to add pagination to it, so I'll probably work on that tonight.
Yeah, I'm gonna have to do some experimentation with that. |
Thanks for the PR! I can try to take a look at it in the coming days, I just need to find a car to test with ^^ I'm guessing there is no built-in pagination support in Android Auto, and I don't think it would be super useful anyway. Search and some voice interactions would definitely be useful down the road (hah), but if basic playback and browsing is working then I guess it qualifies for a beta. |
You can use the emulator! #24 (comment) It's very convenient for debugging too.
Yeah, I think I agree with you. Not sure that pagination should be a priority. I typically just use a playlist anyway lol.
Yeah, 100%. I wanted to incorporate that into this PR, but I was having an issue I didn't really understand where it crashes when searching. EDIT: fixed the crash, was a problem with changing the package name |
Yeah I know about the emulator and have used it last time, but in the end I want to make sure everything works on an actual car too ^^ Regarding voice, how flexible is that? Can it only be used for voice search, or could we enable custom actions, like saying "Start playing Hello by Adele" and it will start an instant mix? |
I know you can do stuff like that with app actions. There's also a version for Android Auto/Automotive. |
The second link you provided seems to be geared towards navigation/Points-of-Interest apps. Here's the one for media apps: https://developer.android.com/training/cars/media#support_voice Seems like it has everything we need. If the user indicates an item type (album, playlist, etc.) we can use that to deal with Jellyfin's poor search, and if they omit the type "Play some music" we could resort to shuffle all for now. Would you like to look into it? :) |
Sure, I have some time the next few days so I'll see if I can understand this and get something usable. |
Awesome. Let me know if you need help with anything! Edit: Just checked it out on the emulator, here are a few things I noticed:
|
Thanks for the feedback, I agree with your observations here.
I was thinking we could replace the genre tab with the home tab. Android Auto by default only allows 4 tabs, and genres don't have instant mixes (though we could shuffle albums within the genre).
I don't think this is possible, but a setting for the default would work.
I don't think I can do anything about these :(, they seem to be built into Android Auto.
Seems like this is related to that section, looks to be possible.
I've done a little troubleshooting, and I'm confused. It seems there may be a bug somewhere causing a conflict between just_audio and the new queue service?
The queue service expects finamp/lib/services/queue_service.dart Lines 94 to 101 in 2ea2156
finamp/lib/services/queue_service.dart Lines 148 to 151 in 2ea2156
I suspect somewhere in just_audio expects it to be the shuffled index and is sending it to the backend (ExoPlayer?), which results in the queue showing the wrong song as selected. To elaborate, the erroneous selected song in queue is in the position of the original (non-shuffled) index, which is why I suspect this. Changing music_player_background_task.dart - queueIndex: event.currentIndex,
+ queueIndex: _player.shuffleModeEnabled && (shuffleIndices?.isNotEmpty ?? false) && event.currentIndex != null ? shuffleIndices!.indexOf(event.currentIndex!) : event.currentIndex, queue_service.dart -int adjustedQueueIndex = (playbackOrder == FinampPlaybackOrder.shuffled &&
- _queueAudioSource.shuffleIndices.isNotEmpty)
- ? _queueAudioSource.shuffleIndices.indexOf(_queueAudioSourceIndex)
- : _queueAudioSourceIndex;
+ int adjustedQueueIndex = _queueAudioSourceIndex; |
We could reduce the number of tabs even further, with a home tab and a library tab? On the library tab we could have a grid with the different categories. Genre mixes should be possible, at least there's a way to add a genre to a mix on the phone 🤔 But maybe that just adds all individual albums, not sure. Can we change the sorting within Android Auto? If something like "Recently Added" is possible, then it should be possible to use the BaseItemDto's SortTitle too. I'll take a look at the modifications to the queue service. just_audio is really opinionated and the layered architecture doesn't make things easier. I've struggled with it for many monhs 🙃 Edit: Genre instant mixes should be a thing, at least it works in the Jellyfin app. No idea why it's hidden in Finamp... |
@puff I managed to fix up the queue based on your proposed changes. There were a few other things I needed to adjust, and I fixed a bug that I introduced a while ago (items in next up were not being reported to the external/OS queue). |
Yeah, I like that idea.
I didn't see a way already implemented in Finamp yet, but yeah it should be possible if the Jellyfin app has it.
Yes, we can sort the MediaItem list before returning from
Looks to be because the Jellyfin api is case-insensitive: I've fixed it and added sort to Android Auto. It uses whatever sort option is selected in the phone app. |
Thanks for fixing that. There are some sorting-related issues that need to be tackled at some point anyway, like #444 or #581, so if you feel like taking a look while you're dealing with sorting anyway, that would be much appreciated. |
I managed to get artwork to work with offline items and (kind've) Android Automotive using the android_content_provider package. The white icon in the middle is the placeholder art. Only problem is that for Android Automotive, we can't use |
Did you manage to take a look at the voice command stuff? Or is there anything that you need help with? :) |
Sorry for not responding earlier, I was a bit busy. Just tested it out and didn't manage to invoke the I guess we should skip this feature for now, including regular search. Search is due for a rewrite soon, and it makes little sense to integrate the old version now... |
I did take the build for a test drive this weekend, and even with only occasional skipping I managed to trigger the deadlock. Audio kept playing (although I think the queue jumped to a different spot), but the app didn't respond via the Android Auto UI nor via the car's physical media buttons. I have an exam coming up on Friday, and I hope to get some work on Finamp done this weekend :) |
I've worked around the issue by implementing the ContentProvider in Kotlin instead of flutter. This doesn't seem ideal though because we can't easily pass things to it from flutter. I think it's probably fine for our use case, since we don't need anything other than the artwork URL. |
So that means everything should be working now? 😁 |
Yeah, everything should be working now. |
Sweet! I tested it an so far everything seems to be working great. Not a single crash or freeze yet. I also finished up the merge, currently testing that. |
Would be nice if you could do another round of testing, focusing especially on the offline stuff you implemented, since I tried to migrate everything to the new system :) |
Had to fix |
I noticed that when you tried to use downloaded items by default even if online, it resulted in Finamp only playing downloaded songs from i.e. albums, even though we could just fetch the other songs from the server. Maybe we could fall back to only downloaded items in case fetching the items from the server fails to due a spotty connection, but I'm not sure if we want to do that in general. We don't do it in the regular app after all, but maybe driving justifies the changed behavior? What do you think? |
@puff do you know of any way to get the currently selected tab in such a way that we could use it do decide what to search for? I'm asking because there are many users that listen to albums, and there currently is no good way to pick albums that are not in the first 100. |
I think we should just retry fetching it until we get a response, or change the timeout to be longer.
We could store it during the |
That was my initial idea as well, but there are also cases where we can enter search (i.e. from the player screen), where it's not clear which tab should be used. Ideally we should just search for all item types, but I think that's a bit too involved for now... |
I also noticed a lot of these errors in the logs:
Any idea what's going on? I suspect it's something to do with the content provider... |
I'll also try to tackle offline voice search tomorrow. That doesn't work at all yet, but should be doable. |
- removes old limitations
Seems like an incompatibility with our content provider and audio_service's
I think it should just prioritize certain types in the results. |
Ah, yeah I enabled that option recently because I was hoping it would avoid the artist sometimes not loading correctly in the Android notification. I'll disable it for now. I'll see what I can do about the search. |
Adds basic Android Auto and Android Automotive support.
Features:
Future features/TODO?
Currently, there is a hard limit of 100 items displayed so the app doesn't crash on large libraries.
// dev notes