How to get MediaRouteSelector to show available MiraCast and Chromecast devices?

柔情痞子 提交于 2019-12-23 19:27:12

问题


I am trying to get my Media Route Selector to show both MiraCast and Chromecast devices. I have a Chromecast receiver app and also make use of the Presentation API in Android so ideally the user should only have to click the media router button and chose the device they have without even having to think about it. I was following this guide (https://developer.android.com/guide/topics/media/mediarouter.html#selector) to achieve this and in the picture it shows both a Chromecast and wireless display available in the route selector. However, after adding the control categories I still only see the Chromecast.

Here is the relevant code.

mMediaRouteSelector = new MediaRouteSelector.Builder()
                .addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
                .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
                .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
                .addControlCategory(CastMediaControlIntent.categoryForCast(CAST_APP_ID))
                .build();

...

mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
                MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);

I have tried changing the callback flag also but saw no change.

EDIT:

I ended up creating a custom dialog factory for the router button and using a separate layout that includes a button that will send the user to wireless display settings. Not exactly the solution I was looking for but it appears that what I was actually trying to do is not supported.

来源:https://stackoverflow.com/questions/29524643/how-to-get-mediarouteselector-to-show-available-miracast-and-chromecast-devices

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