java.lang.Object | |
↳ | android.media.session.MediaController |
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 through MediaSessionManager
if you
hold the "android.permission.MEDIA_CONTENT_CONTROL" permission or directly if
you have a MediaSessionToken
from the session owner.
MediaController objects are thread-safe.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MediaController.Callback | Callback for receiving updates on from the session. | ||||||||||
MediaController.TransportControls | Interface for controlling media playback on a session. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a callback to receive updates from the session.
| |||||||||||
Adds a callback to receive updates from the Session.
| |||||||||||
Send the specified media button event to the session.
| |||||||||||
Get a new MediaController for a MediaSessionToken.
| |||||||||||
Get the current metadata for this session.
| |||||||||||
Get the current playback state for this session.
| |||||||||||
Get the rating type supported by the session.
| |||||||||||
Get a
MediaController.TransportControls instance for this session. | |||||||||||
Stop receiving updates on the specified callback.
| |||||||||||
Sends a generic command to the session.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Adds a callback to receive updates from the session. Updates will be posted on the specified handler's thread.
cb | Cannot be null. |
---|---|
handler | The handler to post updates on. If null the callers thread will be used |
Adds a callback to receive updates from the Session. Updates will be posted on the caller's thread.
cb | The callback object, must not be null |
---|
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. |
---|
Get a new MediaController for a MediaSessionToken. If successful the controller returned will be connected to the session that generated the token.
token | The session token to use |
---|
Get the current metadata for this session.
Get the current playback state for this session.
Get the rating type supported by the session. One of:
Get a MediaController.TransportControls
instance for this session.
Stop receiving updates on the specified callback. If an update has already been posted you may still receive it after calling this method.
cb | The callback to remove |
---|
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 |