Search code examples
androidgoogle-cast

Changing the behavior of the MediaRouteButton?


I have the MediaRouteButton working successfully. However, since I am writing an app that always uses Chromecast, I would like change a couple of behaviors of this button:

1) On app startup, automatically select a device. If there is only one device discovered, automatically select it. If there are multiple, select the previous device selected by the user.

2) If the user manually disconnects using the MediaRouteButton. presses it again to connect and there is only one device on the network, automatically select that one. This is what the YouTube app is doing now - it never prompts me with a list of devices since I only have one Chromecast device on my network.

Any suggestions?


Solution

  • Create your own button for selecting the ChromeCast device. Look at the TicTacToe example which does not use the MediaRouteButton. You can create your own dialog for displaying the list of devices. The logic in the TicTacToe app can also be used to automatically connect to a ChromeCast device.