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.

Cast Extension Artwork metadata not working

See original GitHub issue

As of the recent deprecation of CastPlayer.loaditem() , I have updated to using com.google.android.exoplayer2.MediaMetadata.

Previously, I would add artwork like this and it would appear in the system notification media item as well as the Cast Player ExpandedControlsActivity.

val movieMetadata = MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE)
movieMetadata.addImage(WebImage(Uri.parse(posterImage)))

I am now attempting to use the functions: movieMetadata.setArtworkUri() movieMetadata.setArtworkData()

But they do not result in the image being shown.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dani3l3commented, Jan 25, 2022

Thanks, I appreciate the detailed explanation.

In the code before you have built MediaQueueItems and passed them to loadItems(). Now after the deprecated method has been removed, you need to add the fields to the MediaItem when building it with the MediaItem.Builder. This is the same MediaItem that you use with ExoPlayer. So you need to do this only once and you can use the same MediaItem for both players.

Yes I have done this part.

Because under the hood, CastPlayer is still using MediaQueueItems we need to convert them when passing it to RemoteMediaClient of the Cast SDK. That’s when the MediaItemConverter comes into play.

Yes, I conceptually understand the back and forth that needs to happen.

So you are certainly right that the interface has change. However, I think it’s for the benefit of the user who is building an app with ExoPlayer and CastPlayer. Sorry if this causes some more effort than you planned for migrating to the current version. Please accept my apologies.

I do accept the apologies but yes it does cause more effort. It is something Google keeps doing… for the same reason I am waiting to update billing library because it also has breaking changes. But I digress.

So if you before have used fields for MediaQueueItem that are not copied over by the default converter, you need to create a custom converter (the artwork is an example of missing properties in the current version. We will push an updated DefaultMediaItemConverter to the dev-v2 branch soon, that supports more fields including the artwork out-of-the-box).

Here I tried following the example you gave in this other thread https://github.com/google/ExoPlayer/issues/7915 … but it only partially works, nowadays… that was written a while ago and some more things have changed 😃 … for example the key method .getTag() doesn’t work anymore… that, too, has been since deprecated… how quickly things change! I tried replacing it with just the .tag property… which compiles… only to figure out that the whole playbackProperties (or localConfiguration - they are basically the same stuff, right?) come up as a NULL object at runtime??.. I have not understood why…

return (MediaQueueItem)mediaItem.playbackProperties.getTag();

… so my coverter doesn’t really convert, so far… I managed to wire up the basics because I have the stream URL in another field mediaId of the MediaItem object… so in the converter I was able to rebuild a basic MediaQueueItem object… but indeed it’s not really a ‘conversion’ and I lose all other info/metadata which are needed down the road by the UX…

would you be so kind to point me at a newer example of working code for such a custom converter that would work with the 2.16 version?

Styling MediaRouteControllerDialog falls under what the cast SDK is doing. CastPlayer does not deal with this so I don’t think that changes in the CastPlayer create difficulties with this. Please let me know if you think differently.

You are most probably right… once I manage to have a working converter we will be able to confirm if things are picked up again by the UX elements or not.

Thanks a lot,

0reactions
dani3l3commented, Feb 24, 2022

I don’t have more info at the moment and I have been busy with higher business priorities… for now I postponed the upgrade and kept the old but working stuff.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google cast: How to show metadata in default media player?
Does anybody know how implement this? Below code plays the audio but the player does not show any image or other metadata. Initialization:...
Read more >
Metadata and Cover Art - Firecore
Correcting Metadata​​ Inevitably there will be times when incorrect metadata and cover art is downloaded for one or more files. The good news...
Read more >
Retrieving media metadata | Apple Developer Documentation
This class provides a simple, consistent interface to work with metadata, regardless of the underlying container and metadata formats. Load an asset's metadata....
Read more >
Namespace: cast - Google Developers
Describes the state of a currently running Cast application. Normally, these objects should not be created by the client.
Read more >
Local Media Assets - Movies - Plex Support
The scanners and metadata agents used by Plex will work best when your ... Custom Poster artwork will be detected and used if...
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