Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

Commit 65a27cd

Browse files
marcbaechingerdturner
authored andcommitted
Add JavaDoc for CastMediaItemConverter
1 parent 8cedd8c commit 65a27cd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

common/src/main/java/com/example/android/uamp/media/CastMediaItemConverter.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,18 @@ import com.google.android.gms.cast.MediaMetadata
1212
import com.google.android.gms.cast.MediaQueueItem
1313
import 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

Comments
 (0)