Chromecast的发件人应用程序不检测断线/重新连接 [英] Chromecast Sender App Doesn't Detect Disconnection/Reconnection

查看:254
本文介绍了Chromecast的发件人应用程序不检测断线/重新连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我previously开发一个Android发送应用程序与preVIEW SDK,并发现,当一个的Chromecast被打开或关闭,应用程序很快就发现了这一点,并改变了媒体的路线按钮的状态。

I previously developed an android sender app with the preview SDK and found that when a Chromecast was turned on or off, the app very quickly discovered this and changed the state of the media route button.

然而,随着新的SDK,如果Chromecast已拔出,而应用程序没有连接到它,MediaRouter.Callback.onRouteUnselected()不会被调用和演员图标仍然可见。在即使应用程序被关闭并重新打开某些情况下,onRouteAdded被称为在启动时的previously连接的Chromecast的细节,即使它不插电了,所以没有网络,这表明有某种对缓存的地方。

However with the new SDK, if a Chromecast is unplugged while the app isn't connected to it, MediaRouter.Callback.onRouteUnselected() is never called and the Cast icon remains visible. In some cases even if the app is closed and opened again, onRouteAdded is called on startup with the details of the previously connected Chromecast, even though it's not plugged in anymore and hence not on the network, which suggests that there's some kind of cache somewhere.

我注意到这都与我自己的应用程序(它使用的同伴库),并在GitHub上的例子CastVideos-Android应用程序。这将设置像这样的回调:

I'm noticing this both with my own app (which uses the companion library) and the example CastVideos-android app on github. This sets up the callback like so:

mMediaRouter = MediaRouter.getInstance(context);
mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(
    CastMediaControlIntent.categoryForCast(mApplicationId)).build();

mMediaRouterCallback = new CastMediaRouterCallback(this, context);
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
    MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);

这导致了pretty的粗糙的用户体验 - 有什么办法可以改善?也许有些标志,我可以通过那将执行更加积极的扫描比CALLBACK_FLAG_PERFORM_ACTIVE_SCAN,因此检测的Chromecast不再在网络上?或许一些方法,我可以打的时间间隔再次扫描,并确保的Chromecast仍然存在?我已经通过API来看看,但我看不到任何东西。

This results in a pretty rough user experience - is there any way I can improve it? Perhaps some flag that I can pass that'll perform an even more active scan than CALLBACK_FLAG_PERFORM_ACTIVE_SCAN, hence detecting Chromecasts that are no longer on the network? Or perhaps some method that I can hit at intervals to scan again and make sure the chromecast is still there? I've had a look through the API but I can't see anything.

编辑:。更糟糕的是,我也注意到,如果一个的Chromecast被拔掉,那么你尝试投给它,它就会断开(好),但是不会检测到的Chromecast当它插回去了这是真实的,即使如果你得到了应用程序,然后重新启动它。

Worse still, I've also noticed that if a Chromecast is unplugged then you attempt to cast to it, it will disconnect (good) but won't detect the Chromecast when it's plugged back in. This is true even if you get out of the app and start it up again.

推荐答案

您已经概述是由在SDK,是要在的谷歌Play业务的下一个版本中得到解决的错误行为。

The behavior you have outlined is caused by a bug in the SDK that is going to be addressed in the next release of the Google Play services.

这篇关于Chromecast的发件人应用程序不检测断线/重新连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆