question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change metadata for a MediaItem during playback

See original GitHub issue

I’m having a hard time figuring out how to supply custom metadata for the ExoPlayer (or maybe it’s better to say side-load). We support some sort of radio functionality, which is delivered via ProgressiveMediaSource. The problem is that the radio stream may contain malformed metadata due to the human factor (e.g. incorrect title, missing artwork). However, we have a dedicated “now playing” endpoint on our server that returns 100% accurate metadata (don’t ask me why 😃).

What I need to achieve is to periodically update the metadata (by calling the above mentioned endpoint) (for instance to update the track info in the notification) without re-setting the media item with the radio url. This is because the radio stream url is always the same and we set it only once, while songs on the radio are obviously being changed, and we’d like to reflect the song changes (title, artist, artwork etc) in the notification.

Previously we’ve been using mediaSession.setMetadata() for this purpose, but as we migrated to media2 this method is marked as library restricted, so I don’t think it’s a good option.

Could you please advise the solution?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
icbakercommented, Mar 7, 2022

Sorry for the delay looking into this. Thanks for the repro project, it was really helpful and nice and simple.

This is a limitation of ExoPlayer: It’s not currently possible to change the item metadata of a currently-playing MediaItem - because if you try and change the whole MediaItem it will result in the whole MediaSource being re-created, and playback will not be continuous. It’s the same issue tracked by https://github.com/androidx/media/issues/33.

I’m going to mark this as an enhancement.

0reactions
NikSatyrcommented, Feb 25, 2022

any updates here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to update current media metadata (user rating) without ...
I am using androidx.media3 to develop an audio player app which provides users ... Change metadata for a MediaItem during playback google/ExoPlayer#9978.
Read more >
How to update metadata of currentl… | Apple Developer Forums
I am using TVJS to play a live stream video, and can populate the ... How do I programatically update the mediaItem metadata...
Read more >
Media items - ExoPlayer
In the example below, a media item is built with an ID and some attached metadata: MediaItem mediaItem = new MediaItem.Builder() .
Read more >
MediaItem | Android Developers
A class with information on a single media item with the metadata information. Here are use cases. Specify media items to SessionPlayer for...
Read more >
How to update the default song metadata? - Stack Overflow
By this component, you can update song data in the notification, lock screen, and home screen. Share.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found