@@ -12,7 +12,18 @@ import com.google.android.gms.cast.MediaMetadata
1212import com.google.android.gms.cast.MediaQueueItem
1313import com.google.android.gms.common.images.WebImage
1414
15- class CastMediaItemConverter : MediaItemConverter {
15+ /* *
16+ * A [MediaItemConverter] to convert from a [MediaItem] to a Cast [MediaQueueItem].
17+ *
18+ * It adds all audio specific metadata properties and creates a Cast metadata object of type
19+ * [MediaMetadata.MEDIA_TYPE_MUSIC_TRACK].
20+ *
21+ * To create an artwork for Cast we can't use the standard [MediaItem#mediaMetadata#artworkUri]
22+ * because UAMP uses a content provider to serve cached bitmaps. The URIs starting with `content://`
23+ * are useless on a Cast device, so we need to use the original HTTP URI that the [JsonSource]
24+ * stores in the metadata extra with key `JsonSource.ORIGINAL_ARTWORK_URI_KEY`.
25+ */
26+ internal class CastMediaItemConverter : MediaItemConverter {
1627
1728 private val defaultMediaItemConverter = DefaultMediaItemConverter ()
1829
@@ -53,7 +64,8 @@ class CastMediaItemConverter : MediaItemConverter {
5364 bundle.getString(JsonSource .ORIGINAL_ARTWORK_URI_KEY )?.let {
5465 castMediaMetadata.addImage(WebImage (Uri .parse(it)))
5566 }
56- mediaInfo.setStreamDuration(bundle.getLong(MediaMetadataCompat .METADATA_KEY_DURATION ,0 ))
67+ mediaInfo.setStreamDuration(
68+ bundle.getLong(MediaMetadataCompat .METADATA_KEY_DURATION ,0 ))
5769 }
5870 mediaInfo.setMetadata(castMediaMetadata)
5971 return MediaQueueItem .Builder (mediaInfo.build()).build()
0 commit comments