I am writing an app that utilizes an external display (HDMI and/or wireless miracast or chromecast display) to play video in a Presentation
via the DisplayManager
I am trying to force the audio from that video to play via a bluetooth a2dp profile if one is connected. I find the route info for the bluetooth device easily enough, and select it for the audio route:
final MediaRouter mediaRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
int nRoutes = mediaRouter.getRouteCount();
for (int i = 0; i < nRoutes; i++) {
if (mediaRouter.getRouteAt(i).getDeviceType() == MediaRouter.RouteInfo.DEVICE_TYPE_BLUETOOTH) {
mediaRouter.selectRoute(MediaRouter.ROUTE_TYPE_LIVE_AUDIO, mediaRouter.getRouteAt(i));
break;
}
}
This works, BUT, it causes the wifi display to disconnect completely rather than continue to play the video. How can I tell android that I only want to override the audio route and not the video. Strangely, the RouteInfo
object that has DEVICE_TYPE_BLUETOOTH
indicates that it supports both ROUTE_TYPE_LIVE_AUDIO
and ROUTE_TYPE_LIVE_VIDEO
which doesn't seem right to me.