You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom extras in MediaMetadataCompat not getting populated in "extras" field of MediaMetadata #756
I am trying to migrate one of my applications to media3 with the service components still using legacy implementation (old media libs)
Inside the service components, some custom keys are getting added into the MediaMetadataCompat, but it is not getting populated in the "extras" field of MediaMetadata (extra is coming as null). Why is it so ?
I am using 1.2.0-beta01 version of media3-session library.
It uses known keys in MediaMetadataCompat to populated named/typed fields in MediaMetadata, but doesn't propagate unknown key/values into MediaMetadata.extras.
Can you provide a bit of context about what info you need to propagate across? Is it keys that are defined on MediaMetadataCompat but that don't have a matching field in MediaMetadata, or is it completely custom keys in MediaMetadataCompat? It's not obvious to me that MediaMetadataCompat is intended to support completely custom keys.
@icbaker Yes, it is the keys that are defined in MediaMetadataCompat that does not have a matching field in MediaMetadata.
Standard keys were used to populate most of the values in MediaMetadataCompat , but there are some situations where some custom keys have been used to pass on some values.
Please find the sample code snippet below
val builder=MediaMetadataCompat.Builder()
builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE,"520")
builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE,"AM")
builder.putString("radio_station_frequency_in_hertz","500000")
builder.build()
We are expecting "radio_station_frequency_in_hertz" to be part of the MediaMetadata.extras.
Migrating the service code to use media3 APIs is beyond our control, so it will be better if such custom fields were also included as part of MediaMetadata.extras.
Why can't the entire bundle of MediaMetadataCompat be included as part of MediaMetadata.extras just for backward compatibility? This will help us to continue using media3 APIs.
Activity
icbaker commentedon Oct 23, 2023
The conversion from
MediaMetadataCompattoMediaMetadatais implemented here:media/libraries/session/src/main/java/androidx/media3/session/MediaUtils.java
Lines 435 to 436 in c16accb
It uses known keys in
MediaMetadataCompatto populated named/typed fields inMediaMetadata, but doesn't propagate unknown key/values intoMediaMetadata.extras.Can you provide a bit of context about what info you need to propagate across? Is it keys that are defined on
MediaMetadataCompatbut that don't have a matching field inMediaMetadata, or is it completely custom keys inMediaMetadataCompat? It's not obvious to me thatMediaMetadataCompatis intended to support completely custom keys.Sachin-Radhakrishnan commentedon Oct 23, 2023
@icbaker Yes, it is the keys that are defined in
MediaMetadataCompatthat does not have a matching field inMediaMetadata.Standard keys were used to populate most of the values in
MediaMetadataCompat, but there are some situations where some custom keys have been used to pass on some values.Please find the sample code snippet below
We are expecting "radio_station_frequency_in_hertz" to be part of the
MediaMetadata.extras.Migrating the service code to use media3 APIs is beyond our control, so it will be better if such custom fields were also included as part of
MediaMetadata.extras.Why can't the entire bundle of
MediaMetadataCompatbe included as part ofMediaMetadata.extrasjust for backward compatibility? This will help us to continue using media3 APIs.Sachin-Radhakrishnan commentedon Oct 26, 2023
@icbaker @tianyif Any update on this? Can we expect a fix?
tianyif commentedon Oct 30, 2023
Hi @Sachin-Radhakrishnan, I'm working on a solution to this.
tianyif commentedon Nov 1, 2023
The fix was submitted to the dev branch: 84022ea