How can I get list of all cast devices using cast SDK?

假装没事ソ 提交于 2019-12-11 17:03:11

问题


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).

My list will contain all chrome cast devices and all DIAL protocol supported devices. I am using cast 3 SDK provided in android.


回答1:


    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);
        }
    }


来源:https://stackoverflow.com/questions/47506631/how-can-i-get-list-of-all-cast-devices-using-cast-sdk

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