google / google/ExoPlayer

[Cast] Convert MediaItem.playbackProperties.subtitles to MediaTracks

Open
#8,669 15 comments 0 reactions 1 assignee Assigned to @marcbaechinger View on GitHub
enhancement
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

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`?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.