Uriel Ramírez
Uriel Ramírez

Reputation: 13

MediaQueueItem And RemoteMediaItem, how can i make queue to cast?

As you can see in the code below, I've come across a great Google Cast SDK feature, how to create a play queue?

Right now I have managed to transmit video and information to chrome cast (at the moment), I have ready the .css splash that they request for the start of the application, in fact it is almost ready! ... in Google Devlopers reading the documentation I came across the section "Queueing" which shows the following code:

MediaQueueItem queueItem = new MediaQueueItem.Builder(mediaInfo)
    .setAutoplay(true)
    .setPreloadTime(20)
    .build();

The million dollar questions are...

  1. Where should I put that code?
  2. How can I add lists to Google Cast?
  3. How do I update the lists, once finished?

Upvotes: 1

Views: 1292

Answers (2)

Cheloespinoza
Cheloespinoza

Reputation: 65

First, you need to create an array of MediaQueueitem

private fun buildMediaQueueItem(episodes: Episode): Array<MediaQueueItem> {
    var mediaQueueItemArray = arrayOf<MediaQueueItem>()
    episodes.forEach { episode: Episode ->
        mediaQueueItemArray += (MediaQueueItem.Builder(MediaInfo.Builder()
            .setContentUrl(episode.audioUrl)
            .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
            .setContentType(AUDIO_MPEG)
            .setStreamDuration(episode.duration.toLong())
            .setMetadata(buildMediaMetadata(episode))
            .build()).build())
    }
    return mediaQueueItemArray
}

and then pass it to remoteMediaCliente like this

remoteMediaClient?.queueLoad(mediaQueueArray,startIndex,0,null)

Upvotes: 0

Related Questions