扩展 MediaRouteButton 行为
Extend MediaRouteButton behaviour
我正在构建一个可以投射到 Chromecast 和 AppleTV 设备的应用程序。这些设备的发现工作正常:使用 MediaRouter
发现 ChromeCasts,使用 SSDP 发现 AppleTV。目前,我有一个显示已发现设备组合列表的常规按钮,但我想让它使用花式投射按钮。
是否有一种优雅的方式来扩展 MediaRouteButton
以显示我自己的已发现设备列表,或者我应该使用 cast drawables 从头开始创建自己的按钮?
我知道 MediaRouteButton
class 可以扩展,但我不确定如何将我的扩展按钮应用到通过 xml 声明的按钮。我觉得我错过了一些非常明显的东西,但我还没有找到它。
您应该可以通过使用 MediaRouteProvider APIs. The Cast SDK adds a Cast Media Route Provider and you can build your own provider, for whatever type of devices that you are interested in (there is an android sample that exhibits this but I am not sure how up-to-date it has been kept). If you want to use CastSDK (v3) to handle connection and establishment of sessions to both types of devices (the ones discovered by the Cast SDK itself and the ones you discover through your own provider), you should then use the Cast SDK's SessionProvider. There are posts (such as this) 来完成此操作,询问有关在 Cast SDK v3 中扩展 Session 和 SessionProviders 的问题。
我正在构建一个可以投射到 Chromecast 和 AppleTV 设备的应用程序。这些设备的发现工作正常:使用 MediaRouter
发现 ChromeCasts,使用 SSDP 发现 AppleTV。目前,我有一个显示已发现设备组合列表的常规按钮,但我想让它使用花式投射按钮。
是否有一种优雅的方式来扩展 MediaRouteButton
以显示我自己的已发现设备列表,或者我应该使用 cast drawables 从头开始创建自己的按钮?
我知道 MediaRouteButton
class 可以扩展,但我不确定如何将我的扩展按钮应用到通过 xml 声明的按钮。我觉得我错过了一些非常明显的东西,但我还没有找到它。
您应该可以通过使用 MediaRouteProvider APIs. The Cast SDK adds a Cast Media Route Provider and you can build your own provider, for whatever type of devices that you are interested in (there is an android sample that exhibits this but I am not sure how up-to-date it has been kept). If you want to use CastSDK (v3) to handle connection and establishment of sessions to both types of devices (the ones discovered by the Cast SDK itself and the ones you discover through your own provider), you should then use the Cast SDK's SessionProvider. There are posts (such as this) 来完成此操作,询问有关在 Cast SDK v3 中扩展 Session 和 SessionProviders 的问题。