narek.gevorgyan
narek.gevorgyan

Reputation: 4185

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

Upvotes: 1

Views: 3805

Answers (1)

Michael
Michael

Reputation: 58507

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

Upvotes: 3

Related Questions