Skip to content

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

Closed

Description

@Sachin-Radhakrishnan

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.

Activity

  1. self-assigned this
    on Oct 23, 2023
  2. icbaker commented on Oct 23, 2023

    @icbaker
    Collaborator

    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.

  3. Sachin-Radhakrishnan commented on Oct 23, 2023

    @Sachin-Radhakrishnan
    Author

    @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.

  4. assigned and unassigned on Oct 23, 2023
  5. Sachin-Radhakrishnan commented on Oct 26, 2023

    @Sachin-Radhakrishnan
    Author

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

  6. tianyif commented on Oct 30, 2023

    @tianyif
    Contributor

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

  7. tianyif commented on Nov 1, 2023

    @tianyif
    Contributor

    The fix was submitted to the dev branch: 84022ea

  8. locked and limited conversation to collaborators on Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions