ryanheise / audio_service

Flutter plugin to play audio in the background while the screen is off.
796 stars 476 forks source link

[Android] Extend support for AndroidAuto #941

Closed mcorcuera closed 2 years ago

mcorcuera commented 2 years ago

Feature proposal

audio_service already supports basic functionality for Android Auto. However, the support is limited and there are certain things available on the AndroidAuto media app interface (described here: https://developer.android.com/training/cars/media) which are not available through audio_service. Some of them are:

I will be happy to contribute to this feature as we are planning to add Android Auto support to our podcast app.

ryanheise commented 2 years ago

I welcome contributions, although note that you can already set global extras via:

https://pub.dev/documentation/audio_service/latest/audio_service/AudioServiceConfig/androidBrowsableRootExtras.html

and you can set per-item extras via:

https://pub.dev/documentation/audio_service/latest/audio_service/MediaItem/extras.html

snipd-mikel commented 2 years ago

Thanks for the quick reply! I didn't know about the androidBrowsableRootExtras, it worked as expected.

Regarding the flags on the MediaItem, for what I can see in the code, they are set as the extras of MediaMetadata object created. However, there are some extra flags that need to be set on the MediaItem or the MediaDescription objects. Would it be possible to provide a way to also set the extra flags on those objects?

ryanheise commented 2 years ago

Ah, the intention was for the item extras to transfer across. If it is not working, then would you be interested in contributing a fix?

snipd-mikel commented 2 years ago

Sure! I'm pretty sure they are not propagating but will retest. If that's the case I will be happy to contribute a fix for that.

snipd-mikel commented 2 years ago

I have investigated the issue and it seems that some of the flags were only introduced after version androidx.media 1.5.0, so that's why they were not propagated.

Would it be possible to update the library version?

ryanheise commented 2 years ago

It can be changed in the build.gradle file. If you are able to try that out, let me know if it solves your issue.

snipd-mikel commented 2 years ago

Updating to the new version made the Metadata options available. However, the extras were not being propagated to the MediaItem's description, because on how the description is created as part of the MediaMetadata object. I have made some changes to it on the PR. Let me know what you think.

ryanheise commented 2 years ago

Closed by #943

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service.