Search code examples
androidqueuechromecastgoogle-castmediainfo

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?

Solution

  • Use this method on the Android sender to load a queueItem: https://developers.google.com/android/reference/com/google/android/gms/cast/framework/media/RemoteMediaClient.html#load(com.google.android.gms.cast.MediaLoadRequestData)

    Example: https://developers.google.com/cast/docs/android_sender/integrate#load_media

    1. That will contain this request data: https://developers.google.com/android/reference/com/google/android/gms/cast/MediaLoadRequestData

    2. Inside that is the MediaQueueData: https://developers.google.com/android/reference/com/google/android/gms/cast/MediaQueueData

    ...which contains items and that should be set to the MediaQueueItem(s) from the guide: https://developers.google.com/cast/docs/android_sender/queueing#create_and_load_media_queue_items