1

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?

1 Answer 1

2

Call:

mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.