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 the metadata for a currentMediaItem with CastPlayer #1508

Open
FilipKastrupGP opened this issue Jun 28, 2024 · 4 comments
Open

Comments

@FilipKastrupGP
Copy link

I am working with an audio streaming app.
I have a ReplaceableForwardingPlayer like in the UAMP project.
The forwardingplayer switches between an ExoPlayer and a CastPlayer.

I need to control and change the metadata for a mediaItem.
With the Exoplayer I can just replaceMediaItem(...) and it updates the metadata seamlessly:
With the CastPlayer this is not the case. It reloads the entire mediaItem.

Is there a way to update the metadata on a CastPlayer?

@tonihei
Copy link
Collaborator

tonihei commented Jun 28, 2024

This is not seamlessly supported on CastPlayer at the moment. I can mark it as a feature request but we won't get around to work on it soon.

If you want to add support, I think you can amend CastPlayer.replaceMediaItems to check if just the metadata changed, and if so, call a new method on CastTimelineTracker that updates the internal item data only (without touching the remote cast client at all). The remote cast player metadata won't be updated though in this scenario (that is the title etc you'd see on the cast device). There is a method like queueUpdateItems, but it's documented that it's not possible to update just the metadata once the item has been loaded.

@FilipKastrupGP
Copy link
Author

Thanks for the quick reply.

For anyone else how has this problem,- I made it work by making a copy of the CastPlayer class and changing the empty method

@Override
public void onMetadataUpdated() {}

to

@Override
public void onMetadataUpdated() {
        if (remoteMediaClient != null) {
            currentTimeline = timelineTracker.getCastTimeline(remoteMediaClient);
        }
    }

This depend on the cast-recevier doing the metadata changes to the MediaQueueItem.

@tonihei
Copy link
Collaborator

tonihei commented Jul 1, 2024

making a copy of the CastPlayer class

If you already figured out how to improve this, do you want to upload a PR instead to merge it into our codebase? If not, we can make the same change ourselves too.

@FilipKastrupGP
Copy link
Author

Sure. I'll make a pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants