MediaController2
open classMediaController2: AutoCloseable
| kotlin.Any | |
| ↳ | android.media.MediaController2 |
This API is not generally intended for third party application developers. Use the AndroidX Media3 session Library for consistent behavior across all devices. Allows an app to interact with an active MediaSession2 or a MediaSession2Service which would provide MediaSession2.
Summary
| Nested classes | |
|---|---|
|
This API is not generally intended for third party application developers. |
|
| abstract |
This API is not generally intended for third party application developers. |
| Public methods | |
|---|---|
| open Unit |
cancelSessionCommand(token: Any)Cancels the session command previously sent. |
| open Unit |
close()Closes this resource, relinquishing any underlying resources. |
| open Session2Token? |
Returns |
| open Boolean |
Returns whether the session's playback is active. |
| open Any |
sendSessionCommand(command: Session2Command, args: Bundle?)Sends a session command to the session |
Public methods
cancelSessionCommand
open funcancelSessionCommand(token: Any): Unit
Deprecated: Deprecated in Java.
Cancels the session command previously sent.
| Parameters | |
|---|---|
token |
Any: the token which is returned from sendSessionCommand. This value cannot be null. |
close
open funclose(): Unit
Deprecated: Deprecated in Java.
Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.
| Exceptions | |
|---|---|
java.lang.Exception |
if this resource cannot be closed |
getConnectedToken
open fungetConnectedToken(): Session2Token?
Deprecated: Deprecated in Java.
Returns Session2Token of the connected session. If it is not connected yet, it returns null.
This may differ with the Session2Token from the constructor. For example, if the controller is created with the token for MediaSession2Service, this would return token for the MediaSession2 in the service.
| Return | |
|---|---|
Session2Token? |
Session2Token of the connected session, or null if not connected |
isPlaybackActive
open funisPlaybackActive(): Boolean
Deprecated: Deprecated in Java.
Returns whether the session's playback is active.
| Return | |
|---|---|
Boolean |
true if playback active. false otherwise. |
sendSessionCommand
open funsendSessionCommand(
command: Session2Command,
args: Bundle?
): Any
Deprecated: Deprecated in Java.
Sends a session command to the session
| Parameters | |
|---|---|
command |
Session2Command: the session command. This value cannot be null. |
args |
Bundle?: optional arguments. This value may be null. |
| Return | |
|---|---|
Any |
a token which will be sent together in ControllerCallback.onCommandResult when its result is received. This value cannot be null. |