如何使用Cast SDK获取所有Cast设备的列表? [英] How can I get list of all cast devices using cast SDK?
本文介绍了如何使用Cast SDK获取所有Cast设备的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力获取网络中所有可用的Chrome Cast设备的列表,我能够使其与在操作栏中添加媒体路由器按钮的默认实现一起使用.我要实现的是获取所有可用的铸造设备的列表,包括Fire Stick和智能电视(基本上是所有支持DIAL协议的设备).
I am struggling to get list of all chrome cast devices available in my network, I am able to make it work with there default implementation of adding a media router button in the action bar. What I want to achieve is to get list of all cast devices available including Fire stick and smart TV (basically all the devices which supports DIAL protocol).
我的列表将包含所有chrome Cast设备和所有DIAL协议支持的设备.我正在使用android中提供的cast 3 SDK.
My list will contain all chrome cast devices and all DIAL protocol supported devices. I am using cast 3 SDK provided in android.
推荐答案
MediaRouter router =
MediaRouter.getInstance(a context);
List<MediaRouter.RouteInfo> routes = router.getRoutes();
List<CastDevice> devices = new ArrayList<>();
for (MediaRouter.RouteInfo routeInfo : routes) {
CastDevice device = CastDevice.getFromBundle(routeInfo.getExtras());
if (device != null) {
devices.add(device);
}
}
这篇关于如何使用Cast SDK获取所有Cast设备的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文