MediaRouteButton
class MediaRouteButton : View
The media route button allows the user to select routes and to control the currently selected route.
The application must specify the kinds of routes that the user should be allowed to select by specifying a selector with the setRouteSelector method.
When the default route is selected, the button will appear in an inactive state indicating that the application is not connected to a route. Clicking on the button opens a MediaRouteChooserDialog to allow the user to select a route. If no non-default routes match the selector and it is not possible for an active scan to discover any matching routes, then the button is disabled.
When a non-default route is selected, the button will appear in an active state indicating that the application is connected to a route of the kind that it wants to use. The button may also appear in an intermediary connecting state if the route is in the process of connecting to the destination but has not yet completed doing so. In either case, clicking on the button opens a MediaRouteControllerDialog to allow the user to control or disconnect from the current route.
Prerequisites
To use the media route button, the containing activity must be a subclass ofFragmentActivity.
| See also | |
|---|---|
MediaRouteActionProvider |
Summary
Public constructors |
|---|
MediaRouteButton(context: Context) |
MediaRouteButton(context: Context, attrs: AttributeSet?) |
MediaRouteButton(context: Context, attrs: AttributeSet?, defStyleAttr: Int) |
Public functions |
|
|---|---|
Unit |
This function is deprecated. Use |
MediaRouteDialogFactory |
Gets the media route dialog factory to use when showing the route chooser or controller dialog. |
MediaRouteSelector |
Gets the media route selector for filtering the routes that the user can select using the media route chooser dialog. |
Unit |
|
Unit |
|
Unit |
|
Boolean |
|
Unit |
This function is deprecated. The visibility of the button no longer depends on the availability of routes. |
Unit |
setDialogFactory(factory: MediaRouteDialogFactory)Sets the media route dialog factory to use when showing the route chooser or controller dialog. |
Unit |
Sets a drawable to use as the remote route indicator. |
Unit |
setRouteSelector(selector: MediaRouteSelector)Sets the media route selector for filtering the routes that the user can select using the media route chooser dialog. |
Unit |
setVisibility(visibility: Int) |
Boolean |
Show the route chooser or controller dialog. |
Protected functions |
|
|---|---|
Unit |
|
Array<Int> |
onCreateDrawableState(extraSpace: Int) |
Unit |
|
Unit |
|
Boolean |
verifyDrawable(who: Drawable) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
MediaRouteButton
MediaRouteButton(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
Public functions
funenableDynamicGroup(): Unit
Enables dynamic group feature. With this enabled, a different set of MediaRouteChooserDialog and MediaRouteControllerDialog is shown when the button is clicked. If a media route provider supports dynamic group, the users can use that feature with the dialogs.
getDialogFactory
fun getDialogFactory(): MediaRouteDialogFactory
Gets the media route dialog factory to use when showing the route chooser or controller dialog.
| Returns | |
|---|---|
MediaRouteDialogFactory |
The dialog factory, never null. |
getRouteSelector
fun getRouteSelector(): MediaRouteSelector
Gets the media route selector for filtering the routes that the user can select using the media route chooser dialog.
| Returns | |
|---|---|
MediaRouteSelector |
The selector, never null. |
setDialogFactory
fun setDialogFactory(factory: MediaRouteDialogFactory): Unit
Sets the media route dialog factory to use when showing the route chooser or controller dialog.
| Parameters | |
|---|---|
factory: MediaRouteDialogFactory |
The dialog factory, must not be null. |
setRemoteIndicatorDrawable
fun setRemoteIndicatorDrawable(d: Drawable?): Unit
Sets a drawable to use as the remote route indicator.
setRouteSelector
fun setRouteSelector(selector: MediaRouteSelector): Unit
Sets the media route selector for filtering the routes that the user can select using the media route chooser dialog.
| Parameters | |
|---|---|
selector: MediaRouteSelector |
The selector, must not be null. |
showDialog
fun showDialog(): Boolean
Show the route chooser or controller dialog.
If the default route is selected, then shows the route chooser dialog. Otherwise, shows the route controller dialog to offer the user a choice to disconnect from the route or perform other control actions such as setting the route's volume.
Dialog types can be set by setting MediaRouterParams to the router.
The application can customize the dialogs by calling setDialogFactory to provide a customized dialog factory.
| Returns | |
|---|---|
Boolean |
True if the dialog was actually shown. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
if the activity is not a subclass of |
| See also | |
|---|---|
setDialogType |
|
setOutputSwitcherEnabled |