我能够使用MediaRouter和MediaRouterSelector成功连接并将我的自定义演示文稿视图投射到辅助显示器(电视) 以初始化 MediaRouter 这是我的代码
mSelector = MediaRouteSelector.Builder()
.addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
.addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.build()
用于媒体路由器回调
private val mMediaRouterCallback: MediaRouter.Callback = object : MediaRouter.Callback() {
// Return a custom callback that will simply log all of the route events
// for demonstration purposes.
override fun onRouteAdded(router: MediaRouter, route: MediaRouter.RouteInfo) {
Log.d(TAG, "onRouteAdded: route=$route")
}
override fun onRouteChanged(router: MediaRouter, route: MediaRouter.RouteInfo) {
Log.d(TAG, "onRouteChanged: route=$route")
}
override fun onRouteRemoved(router: MediaRouter, route: MediaRouter.RouteInfo) {
Log.d(TAG, "onRouteRemoved: route=$route")
}
override fun onRouteSelected(router: MediaRouter, route: MediaRouter.RouteInfo) {
Log.d(TAG, "onRouteSelected: route=$route")
if (route.supportsControlCategory(
MediaControlIntent.CATEGORY_REMOTE_PLAYBACK
)
) {
updateRemotePlayer(route);
} else {
updatePresentation(route);
}
}
通过使用此代码,我在辅助显示器上看到了我的自定义视图,但我无法路由音频我不知道出了什么问题,我是否缺少任何配置或任何标志,请给我任何链接或告诉我有什么问题我的代码?