MediaRouteButton animation when connected to an application

How do I change the behavior MediaRouteButtonto show loading animations until the Chromecast application starts up, like HBO or Netflix, and not just when connected to Chromecast?

+4
source share
3 answers

You can create your own CustomMediaRouteActionProvider extends MediaRouteActionProviderand redefine onCreateMediaRouteButton() so you also need to create your own CustomMediaRouteButton. In this custom button, you can easily switch between states. When you receive a callback onApplicationConnected(), switch the state of the button to connect, while showing this state (animation):

private static final int[] CHECKABLE_STATE_SET = {android.R.attr.state_checkable};

MediaRouter, MediaRouterLibrarySource

0

Cast Companion ( ) . onApplicationConnected ~ 3 , . "mr_ic_media_route_mono_dark", , , . , , .

, , AnimationDrawable MediaRouterButton , .

, onDeviceSelected:

AnimationDrawable connecting = (AnimationDrawable) getResources().getDrawable(R.drawable.mr_ic_media_route_connecting_mono_dark);
mMediaRouteButton.setRemoteIndicatorDrawable(connecting);
connecting.start();
0

Netflix ( HBO), . ( ), , . , , , , ( ) .

-1

All Articles