2

I've followed the instruction from Google on how to cast media metadata to chromecast, the initial loading is fine, it will show the title, image and play the stream, but my problem is that I am streaming a live audio stream and need to update the metadata from time to time without having to buffer the audio again.


This is a sample of my code:

    override fun loadMediaLoadRequestData(request: PlatformBridgeApis.MediaLoadRequestData?) 
    {
        if (request == null) return
        val remoteMediaClient: RemoteMediaClient = remoteMediaClient ?: return
        val mediaLoadRequest = getMediaLoadRequestData(request)
        remoteMediaClient.load(mediaLoadRequest)
    }

    fun getMediaLoadRequestData(request: PlatformBridgeApis.MediaLoadRequestData): MediaLoadRequestData {
        val mediaInfo = getMediaInfo(request.mediaInfo)

        return MediaLoadRequestData.Builder()
            .setMediaInfo(mediaInfo)
            .setAutoplay(request.shouldAutoplay)
            .setCurrentTime(request.currentTime)
            .build()
    }
    fun getMediaInfo(mediaInfo: PlatformBridgeApis.MediaInfo?): MediaInfo? {
        if (mediaInfo == null) return null

        val streamType = getStreamType(mediaInfo.streamType)
        val metadata = getMediaMetadata(mediaInfo.mediaMetadata)
        val mediaTracks = mediaInfo.mediaTracks.map { getMediaTrack(it) }
        val customData = JSONObject(mediaInfo.customDataAsJson ?: "{}")

        return MediaInfo.Builder(mediaInfo.contentId)
            .setStreamType(streamType)
            .setContentType(mediaInfo.contentType)
            .setMetadata(metadata)
            .setMediaTracks(mediaTracks)
            .setStreamDuration(mediaInfo.streamDuration)
            .setCustomData(customData)
            .build()
    }

Does anyone have any suggestion on how to modify loadMediaLoadRequestData in order to trigger the Chromecast receiver to update only the MediaMetadata and not have the stream buffer again?

2
  • As a sidenote I'm using the default media receiver app id CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID. Do I need to make a custom receiver for my issue?
    – bypass112
    Commented Jun 28, 2022 at 9:38
  • Try updating on the receiver since the phone can become disconnected and the receiver should update itself as needed. Commented Jun 30, 2022 at 6:44

0