Skip to content
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

Custom extras in MediaMetadataCompat not getting populated in "extras" field of MediaMetadata #756

Sachin-Radhakrishnan opened this issue Oct 22, 2023 · 5 comments


Copy link

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.

Copy link

icbaker commented Oct 23, 2023

The conversion from MediaMetadataCompat to MediaMetadata is implemented here:

public static MediaMetadata convertToMediaMetadata(
@Nullable MediaMetadataCompat metadataCompat, @RatingCompat.Style int ratingType) {

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.

Copy link

@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()

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.

Copy link

@icbaker @tianyif Any update on this? Can we expect a fix?

Copy link

tianyif commented Oct 30, 2023

Hi @Sachin-Radhakrishnan, I'm working on a solution to this.

Copy link

tianyif commented Nov 1, 2023

The fix was submitted to the dev branch: 84022ea

@tianyif tianyif closed this as completed Nov 1, 2023
@androidx androidx locked and limited conversation to collaborators Jan 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

4 participants