Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update the volume indicator provided by the MinimalMediaRouteProvider

Tags:

chromecast

When registering the MinimalMediaRouteProvider/MediaRouteButton from Androids Chromecast SDK, we get a standard dialog for connecting to existing Cromecast Devices. Once connected to the device, same dialog also provides a way to set the volume using a draggable seek bar. I am having trouble synchronizing the position of this volume seek bar with the actual volume that is already set in the Chromecast device.

As part of registering the MinimalMediaRouteProvider we provide a com.google.cast.MediaRouteAdapter implementation. The onSetVolume(volume) of this interface is called when the user drags the volume seekBar above. This gives us a god way to update the volume level of the connected chromecast channel by using messageStream.setVolume(volume).

The problem is that once we update the volume, there is no way to tell back the MinimalMediaRouteProvider UI that the volume has changed so it can position itself accordingly - currently it always shows the volume as 0.

What is the proper way to notify the MinimalMediaRouteProvider about the current volume level so it can update its volume UI?

Looking at the MediaRoute sample included with support library 7, there seem to be a way to create MediaRouteDescriptor, update the volume there and thus communicate this back to the MediaRouteProvider, but but it is not very clear how to do this in the content of Chromecast/MinimalMediaRouteProvider.

like image 688
user2697829 Avatar asked Nov 11 '22 23:11

user2697829


1 Answers

You can call MediaRouteStateListener.onVolumeChanged() to update the volume seekbar.

I have a more detailed answer here: https://stackoverflow.com/a/18867128/1334870

like image 113
Allan Sun Avatar answered Jan 04 '23 03:01

Allan Sun