Android Sender App getting timeout when trying to connect to Chromecast

妖精的绣舞 提交于 2019-12-12 03:34:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!