androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.75k stars 424 forks source link

MediaMetadataCompat title item, how avoid clickable or browsing - Android Auto #1720

Open billyjoker opened 2 months ago

billyjoker commented 2 months ago

Hi I am facing an issue using MediaMetadataCompat for Android Auto extension apps. I am trying to create a head title before the items, but that title has the click feautre active to browse or play and I do not the way to disable it, so I do not want it as clickable, only just as a header

            val headerMediaItem = MediaMetadataCompat.Builder().apply {
                putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, "HEADER_ID")
                putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Header items title")
                flag = MediaBrowserCompat.MediaItem.FLAG_PLAYABLE // FLAG_BROWSABLE both are clickables
            }.build()

I guess it must to be a way to create "dumb" items, not playable, not browsable, but I did not figured out.

Thanks in advance

rohitjoins commented 2 months ago

To clarify, when setting the flags for the MediaBrowserCompat.MediaItem, the flag is indeed an integer, and by passing 0, you're explicitly stating that there should be no actions (neither FLAG_PLAYABLE nor FLAG_BROWSABLE):

val headerMediaItem = MediaMetadataCompat.Builder().apply {
    putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, "HEADER_ID")
    putString(MediaMetadataCompat.METADATA_KEY_TITLE, "Header items title")
    flag = 0 // no flags, making it non-clickable
}.build()
billyjoker commented 2 months ago

falg = 0 has no effect, it is clickable anyway

It seems that migrating to media3 there is an attribute to make it, but migrating now for me it is not a choice

rohitjoins commented 2 months ago

Apologies, my mistake. I'll hand this over to @marcbaechinger, who is an expert in this area.

billyjoker commented 2 months ago

Hi @marcbaechinger any ideas on this one?

billyjoker commented 2 months ago

@marcbaechinger any thoughts on this one ?

billyjoker commented 1 month ago

Hi I finally solved it adding a extra with a flag from MediaConstants called DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE. So adding it to a group of elements with a title, it is placed as a header with the proper stylement.