这是indexloc提供的服务,不要输入任何密码
Skip to content

Change metadata for a MediaItem during playback #9978

@NikSatyr

Description

@NikSatyr

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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions