I have an application which allows to stream content to chromecast. According to app logic only one device can be connected to chromecast
When we connecting to receiver we are using:
Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions
.builder(mSelectedDevice, mCastClientListener);
GoogleApiClient mApiClient= new GoogleApiClient.Builder(mContext)
.addApi(Cast.API, apiOptionsBuilder.build())
.addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mConnectionFailedListener)
.build();
mApiClient.connect();
when chromecast is connected succesfully, we launch reciever
Cast.CastApi.launchApplication(mApiClient, mChromeCastAppId, true)
.setResultCallback(
new ResultCallback<Cast.ApplicationConnectionResult>() {
@Override
public void nResult(Cast.ApplicationConnectionResult result) {
//do logic when successfully connected
}
}
});
If other sender connects to device, that is already controlled by first device and playing stream, it restarts reciever and first device gets 2005 error in onApplicationDisconnected
callback, but the MediaRouteButton still have a status like it’s connected to device. And I found no methods to reset route.
If I tap MediaRouteButton, I can see the dialog, that allows me to control volume and to disconnect from the chromecast.
That's confusing for the user. How can I reset MediaRouteButton?
Call:
mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute())