问题
I am writing an Android App which is playing YouTube videos. I am working on adding Chromecast support to my app. I learnt from various questions posted on Stack Overflow that YouTube SDK does not provide direct APIs to cast videos from your own app. Following the suggestions provided, I wrote my own custom receiver and have published it too. However, when I am calling launchApplication from my app, I am always getting status as 15 in onResult.
Cast.CastApi.launchApplication(mApiClient, APP_ID).setResultCallback(
new ResultCallback<Cast.ApplicationConnectionResult>() {
@Override
public void onResult(Cast.ApplicationConnectionResult applicationConnectionResult) { }
}
I learnt that 15 means Timeout. But my receiver does get launched and I am able to see my HTML page getting loaded on TV when I connect to Chromecast through app.
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(CastMediaControlIntent.categoryForCast(APP_ID)).build();
mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
mMediaRouterCallback = new MediaRouterCallback();
As my lauchApplication call fails, my sendMessage is not able to send the required signal to the Chromecast.
I am very new to chromecast and I have limited experience in working on it's integration with android app. I would really appreciate if anyone can tell me, what could be an issue.
来源:https://stackoverflow.com/questions/36076298/android-sender-app-getting-timeout-when-trying-to-connect-to-chromecast