Exoplayer: How to get metadata information like artist, genre, etc?

Created on 18 Sep 2020  路  5Comments  路  Source: google/ExoPlayer

I analyzed the references but was only able to find the title and url in the Metadata object. In my project I need more info like genre and artist. There isnt a way to get more information? Thanks in advance.

duplicate question

All 5 comments

The MediaItem needs to be built by yourself with a builder. There is currently no support to automatically include the metadata of the media in the media item. We released a MetadataRetriever with 2.12 which allows to read metadata from a given media item stream/file.

I close this issue as a duplicate of https://github.com/google/ExoPlayer/issues/3609. Please join the conversation there.

The MediaItem needs to be built by yourself with a builder. There is currently no support to automatically include the metadata of the media in the media item. We released a MetadataRetriever with 2.12 which allows to read metadata from a given media item stream/file.

I close this issue as a duplicate of #3609. Please join the conversation there.

Thanks Marc!
Any suggestion how to use it in case of media is represented by bytes array. Can't get uri or path to it, just a pure bytes array.
Thanks in advance.

Sorry Yuriy! I didn't see your comment because it's closed Aside: You can reopen an issue if you think it makes sense (it makes sense in this case:). If an issue is closed it's not really visible anymore.

You can pass your own implementation of MediaSourceFactory to one of the static methods. The media item will then be passed to the createMediaSource method of the factory. Your factory then just uses a ProgressiveMediaSourceFactory to create the source and you can inject a ByteArrayDataSource which reads from your byte array.

Please look whether that works for you. Happy to help out some more if needed.

EDIT: (or actually you can probably create a ProgressiveMediaSourceFactory directly and pass that ByteArrayDataSource to the constructor of it. No need for a composition)

Hey Marc,
Thanks a lot for advice. I will take a look. Meanwhile, I used MediaMetadataRetriever and it works as I need. I provided my own imp of MediaDataSource which reads bytes as needed.

Ha! Great! You don't even need me! :D

Was this page helpful?
0 / 5 - 0 ratings