我可以通过编程检测是否有当前的WiFi网络上的任何的Chromecast设备? [英] Can i programatically detect if there are any Chromecast devices on the current WiFi network?

查看:177
本文介绍了我可以通过编程检测是否有当前的WiFi网络上的任何的Chromecast设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能检测是否有当前WiFi网络上的任何的Chromecast设备。我见过有一个演员的SDK,但我无法找到搜索设备什么。从未接触过此SDK之前工作过,有可能是我可能忽略了它。

Is it possible to detect if there are any Chromecast devices on the current WiFi network. I've seen that there's a Cast SDK but I couldn't find anything about searching for devices. Having never worked with this SDK before, it is possible that I may have overlooked it.

推荐答案

您可以不使用铸按钮进行搜索;您需要使用从V7支持库媒体路由器(这需要V7 appcompat支持以及),然后从你的code获得媒体路由器的一个实例,定义一个选择器(这基本上是一个过滤器,有可能缩小你有兴趣),然后设备添加一个回调来启动发现。随着设备被发现(异步),您的回调将被调用。看看这个样本项目,特别是这个<一href="https://github.com/googlecast/MediaRouter-Cast-Button-android/blob/master/src/com/example/mediarouter/MediaRouterDiscoveryActivity.java"相对=nofollow>类这不正是你想要的。

You can perform discovery without using the cast button; you need to use media router from v7 support library (which needs the v7 appcompat support as well) and then get an instance of the media router from your code, define a selector (which is basically a filter to possibly narrow down the devices that you are interested in) and then add a callback to start discovery. As devices are discovered (asynchronously), your callbacks will be called. Take a look at this sample project, specially this class which does exactly what you want.

这篇关于我可以通过编程检测是否有当前的WiFi网络上的任何的Chromecast设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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