java.lang.Object | |
↳ | android.media.MediaRouter |
MediaRouter allows applications to control the routing of media channels and streams from the current device to external speakers and destination devices.
A MediaRouter is retrieved through Context.getSystemService()
of a Context.MEDIA_ROUTER_SERVICE
.
The media router API is not thread-safe; all interactions with it must be done from the main thread of the process.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MediaRouter.Callback | Interface for receiving events about media routing changes. | ||||||||||
MediaRouter.RouteCategory | Definition of a category of routes. | ||||||||||
MediaRouter.RouteGroup | Information about a route that consists of multiple other routes in a group. | ||||||||||
MediaRouter.RouteInfo | Information about a media route. | ||||||||||
MediaRouter.SimpleCallback | Stub implementation of MediaRouter.Callback . |
||||||||||
MediaRouter.UserRouteInfo | Information about a route that the application may define and modify. | ||||||||||
MediaRouter.VolumeCallback | Interface for receiving events about volume changes. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | ROUTE_TYPE_LIVE_AUDIO | Route type flag for live audio. | |||||||||
int | ROUTE_TYPE_LIVE_VIDEO | Route type flag for live video. | |||||||||
int | ROUTE_TYPE_USER | Route type flag for application-specific usage. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a callback to listen to events about specific kinds of media routes.
| |||||||||||
Add an app-specified route for media to the MediaRouter.
| |||||||||||
Remove all app-specified routes from the MediaRouter.
| |||||||||||
Create a new route category.
| |||||||||||
Create a new route category.
| |||||||||||
Create a new user route that may be modified and registered for use by the application.
| |||||||||||
Return the
category at the given index. | |||||||||||
Return the number of
categories currently
represented by routes known to this MediaRouter. | |||||||||||
Return the route at the specified index.
| |||||||||||
Return the number of
routes currently known
to this MediaRouter. | |||||||||||
Return the currently selected route for any of the given types
| |||||||||||
Remove the specified callback.
| |||||||||||
Remove an app-specified route for media from the MediaRouter.
| |||||||||||
Select the specified route to use for output of the given media types.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Route type flag for live audio.
A device that supports live audio routing will allow the media audio stream to be routed to supported destinations. This can include internal speakers or audio jacks on the device itself, A2DP devices, and more.
Once initiated this routing is transparent to the application. All audio played on the media stream will be routed to the selected destination.
Route type flag for live video.
A device that supports live video routing will allow a mirrored version
of the device's primary display or a customized
Presentation
to be routed to supported destinations.
Once initiated, display mirroring is transparent to the application.
While remote routing is active the application may use a
Presentation
to replace the mirrored view
on the external display with different content.
Route type flag for application-specific usage.
Unlike other media route types, user routes are managed by the application. The MediaRouter will manage and dispatch events for user routes, but the application is expected to interpret the meaning of these events and perform the requested routing tasks.
Add a callback to listen to events about specific kinds of media routes. If the specified callback is already registered, its registration will be updated for any additional route types specified.
types | Types of routes this callback is interested in |
---|---|
cb | Callback to add |
Add an app-specified route for media to the MediaRouter.
App-specified route definitions are created using createUserRoute(RouteCategory)
info | Definition of the route to add |
---|
Remove all app-specified routes from the MediaRouter.
Create a new route category. Each route must belong to a category.
name | Name of the new category |
---|---|
isGroupable | true if routes in this category may be grouped with one another |
Create a new route category. Each route must belong to a category.
nameResId | Resource ID of the name of the new category |
---|---|
isGroupable | true if routes in this category may be grouped with one another |
Create a new user route that may be modified and registered for use by the application.
category | The category the new route will belong to |
---|
Return the category
at the given index.
Valid indices are in the range [0-getCategoryCount).
index | which category to return |
---|
Return the number of categories
currently
represented by routes known to this MediaRouter.
Return the route at the specified index.
index | index of the route to return |
---|
Return the number of routes
currently known
to this MediaRouter.
Return the currently selected route for any of the given types
type | route types |
---|
Remove the specified callback. It will no longer receive events about media routing.
cb | Callback to remove |
---|
Remove an app-specified route for media from the MediaRouter.
info | Definition of the route to remove |
---|
Select the specified route to use for output of the given media types.
types | type flags indicating which types this route should be used for. The route must support at least a subset. |
---|---|
route | Route to select |