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

Add util to convert Metadata into MediaMetadataCompat #5031

Open
martijn00 opened this issue Oct 31, 2018 · 7 comments
Open

Add util to convert Metadata into MediaMetadataCompat #5031

martijn00 opened this issue Oct 31, 2018 · 7 comments
Assignees

Comments

@martijn00
Copy link

Issue description

Currently it's hard to extract metadata information and using it in the MediaSessionConnector. To make it easier i would suggest to add a conversion util that converts Metadata into a MediaMetadataCompat which can already be converted into a MediaDescriptionCompat.

This way it could be used to updated metadata on notifications, lockscreen and cast.

Reproduction steps

None

Link to test content

None

Version of ExoPlayer being used

2.9.0

Device(s) and version(s) of Android being used

All

A full bug report captured from the device

None

@marcbaechinger
Copy link
Contributor

Currently it's hard to extract metadata information

From where do you extract that metadata?

@martijn00
Copy link
Author

@martijn00
Copy link
Author

Also related to #3609

@marcbaechinger
Copy link
Contributor

This would help you for providing a notification of the item which is currently playing and the metadata of the media session. You still have to provide MediaDescriptionCompat for queue items which have never been played. Do I understand correctly?

@martijn00
Copy link
Author

@marcbaechinger for me this would especially be useful when the ID3 tags of a media file are filled with in the metadata.

If it was possible to extract ID3 from a file or url into a MediaDescriptionCompat before actually playing would work for the before case. Like the existing MediaMetadataRetriever in Android, but then using Exoplayer.

For the MediaSessionConnector it would be useful to do the same, and provide a way to pass in ExoPlayer Metadata into a util that converts it into a MediaDescriptionCompat which then will be used in the notification.

Partial reason for all of this would also be performance, as it is hard to make a performant MediaMetadataRetriever implementation which handles things like covers etc.

@martijn00
Copy link
Author

martijn00 commented May 8, 2019

@marcbaechinger Would it be an idea to add FFmpegMediaMetadataRetriever as a plugin for this?

See Usage of how they extract metadata.

I still think there are a lot of use cases for this issue, especially around the notifications and mediasession integration. Currently it's hard to get any information out of a media source in exoplayer. One of the examples given is:

@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
  for (int i = 0; i < trackGroups.length; i++) {
    TrackGroup trackGroup = trackGroups.get(i);
    for (int j = 0; j < trackGroup.length; j++) {
      Metadata trackMetadata = trackGroup.getFormat(j).metadata;
      if (trackMetadata != null) {
        // We found metadata. Do something with it here!
      }
    }
  }
}

There is just no way to actually do something with the metadata that is found there. It should be possible to create a list of MediaSource items based on Uri's and pass that to a ConcatenatingMediaSource. Based on that the metadata should be retrieved, and shown in the Notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants