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

How to Update Metadata of Already Added MediaItems? #337

Closed
XuQK opened this issue Apr 19, 2023 · 4 comments
Closed

How to Update Metadata of Already Added MediaItems? #337

XuQK opened this issue Apr 19, 2023 · 4 comments
Assignees

Comments

@XuQK
Copy link

XuQK commented Apr 19, 2023

After setting the playlist using controller.setMediaItems(), is there a way to directly modify the already set MediaItem?
My project plays local audio files, and I use MediaMetadataRetriever in the onAddMediaItems callback of the Service to parse the files to obtain the actual music name, duration, and other information. When there are a lot of audio files (1k+), the parsing speed is very slow.
So, is it possible to set temporary information in onAddMediaItems, then parse it in the background using MediaMetadataRetriever, and replace the parsed information in the already added MediaItem after parsing is complete? Or is there a better approach?

@christosts
Copy link
Contributor

This looks like a duplicate of #33, so I'll close this. Please re-open you think #33 does not address your use-case.

@tonihei
Copy link
Collaborator

tonihei commented Apr 19, 2023

One more note/question: ExoPlayer and most other players will parse the media metadata when trying to play a file at the latest. So unless you need to know all metadata in advance (e.g. to display it to a user), there is actually no need to do any of the background service logic you describe here.

@XuQK
Copy link
Author

XuQK commented Apr 20, 2023

One more note/question: ExoPlayer and most other players will parse the media metadata when trying to play a file at the latest. So unless you need to know all metadata in advance (e.g. to display it to a user), there is actually no need to do any of the background service logic you describe here.

Yes, I do need to show the entire playlist to the user.
And I didn't find any place in ExoPlayer or Media3 that actively parses the metadata of the resource. The only MediaItem in the callback of theonMediaItemTransitionmethod is just the result of my parsing inonAddMediaItems, and there are no redundant titles or Artist and other information, can you give me more information?

@tonihei
Copy link
Collaborator

tonihei commented Apr 20, 2023

Thanks for the clarification. Just for completeness: Once we get around to fix google/ExoPlayer#4727, you really don't need your workaround anymore because ExoPlayer would take care of reading all metadata initially if requested.

@androidx androidx locked and limited conversation to collaborators Jun 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants