Change metadata for a MediaItem during playback
See original GitHub issueI’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:
- Created 2 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
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 wholeMediaItem
it will result in the wholeMediaSource
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.
any updates here?