| java.lang.Object | |
| ↳ | android.support.v4.media.session.MediaControllerCompat |
Allows an app to interact with an ongoing media session. Media buttons and other commands can be sent to the session. A callback may be registered to receive updates from the session, such as metadata and play state changes.
A MediaController can be created if you have a MediaSessionCompat.Token
from the session owner.
MediaController objects are thread-safe.
This is a helper for accessing features in MediaSession
introduced after API level 4 in a backwards compatible fashion.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| MediaControllerCompat.Callback | Callback for receiving updates on from the session. | ||||||||||
| MediaControllerCompat.PlaybackInfo | Holds information about the way volume is handled for this session. | ||||||||||
| MediaControllerCompat.TransportControls | Interface for controlling media playback on a session. | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Creates a media controller from a session.
| |||||||||||
Creates a media controller from a session token which may have
been obtained from another process.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Send the specified media button event to the session.
| |||||||||||
Gets the underlying framework
MediaController object.
| |||||||||||
Get the current metadata for this session.
| |||||||||||
Get the current playback info for this session.
| |||||||||||
Get the current playback state for this session.
| |||||||||||
Get the rating type supported by the session.
| |||||||||||
Get a
MediaControllerCompat.TransportControls instance for this session.
| |||||||||||
Adds a callback to receive updates from the Session.
| |||||||||||
Adds a callback to receive updates from the session.
| |||||||||||
Sends a generic command to the session.
| |||||||||||
Stop receiving updates on the specified callback.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Creates a media controller from a session.
| session | The session to be controlled. |
|---|
Creates a media controller from a session token which may have been obtained from another process.
| sessionToken | The token of the session to be controlled. |
|---|
| RemoteException | if the session is not accessible. |
|---|
Send the specified media button event to the session. Only media keys can be sent by this method, other keys will be ignored.
| keyEvent | The media button event to dispatch. |
|---|
Gets the underlying framework MediaController object.
This method is only supported on API 21+.
MediaController object,
or null if none.
Get the current metadata for this session.
Get the current playback info for this session.
Get the current playback state for this session.
Get the rating type supported by the session. One of:
Get a MediaControllerCompat.TransportControls instance for this session.
Adds a callback to receive updates from the Session. Updates will be posted on the caller's thread.
| callback | The callback object, must not be null. |
|---|
Adds a callback to receive updates from the session. Updates will be posted on the specified handler's thread.
| callback | The callback object, must not be null. |
|---|---|
| handler | The handler to post updates on. If null the callers thread will be used. |
Sends a generic command to the session. It is up to the session creator to decide what commands and parameters they will support. As such, commands should only be sent to sessions that the controller owns.
| command | The command to send |
|---|---|
| params | Any parameters to include with the command |
| cb | The callback to receive the result on |
Stop receiving updates on the specified callback. If an update has already been posted you may still receive it after calling this method.
| callback | The callback to remove |
|---|