Skip to content Skip to sidebar Skip to footer

Android - Getting Current Audio/video Output

Is there a some possibility to get current Audio/Video output mode on Android(like HDMI,SPDIF etc) using Android SDK? Android >4.0

Solution 1:

Starting with API level 16 (Jellybean) there's the MediaRouter API which allows you to get some information about the current audio/video routing. To get routing info you'd use the getSelectedRoute method, with the ROUTE_TYPE_LIVE_AUDIO or ROUTE_TYPE_LIVE_VIDEO flag. This gives you a RouteInfo object, through which you can get the name of the route using the getName method.

For example:

MediaRouter mr = (MediaRouter)getSystemService(Context.MEDIA_ROUTER_SERVICE);
RouteInfo ri = mr.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_AUDIO);
if ("HDMI".equals(ri.getName().toString()) {
    // do something...
}

Post a Comment for "Android - Getting Current Audio/video Output"