Skip to content

[Cast] Convert MediaItem.playbackProperties.subtitles to MediaTracks #8669

@gsavvid

Description

@gsavvid

Previously, I would set the metadata like this:

val movieMetadata = MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE)
movieMetadata.putString(MediaMetadata.KEY_TITLE, title)
movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, subtitle)
movieMetadata.addImage(WebImage(Uri.parse(posterImage)))

val mediaInfoBuilder = MediaInfo.Builder(media.mediaUrl)
       .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
       .setMetadata(movieMetadata)

player.loadItem(MediaQueueItem.Builder(mediaInfoBuilder.build()).build(), TimeUnit.SECONDS.toMillis(position))

Where MediaMetadata in the above example is com.google.android.gms.cast.MediaMetadata. Now that CastPlayer.loadItem() is deprecated, I want to replace it with Player.setMediaItem() but I can't find how to pass the same metadata to a MediaItem. I know that it accepts com.google.android.exoplayer2.MediaMetadata but this currently only has a title property.

So my question is how can I set the title, subtitle, and image to be displayed in the cast receiver app using a MediaItem?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions