MediaController2
open class MediaController2 : AutoCloseable
kotlin.Any | |
↳ | android.media.MediaController2 |
This API is not generally intended for third party application developers. Use the AndroidX Media2 session Library for consistent behavior across all devices. Allows an app to interact with an active MediaSession2
or a MediaSession2Service
which would provide MediaSession2
. Media buttons and other commands can be sent to the session.
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() |
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 fun cancelSessionCommand(token: Any): Unit
Cancels the session command previously sent.
Parameters | |
---|---|
token |
Any: the token which is returned from sendSessionCommand . This value cannot be null . |
close
open fun close(): Unit
Exceptions | |
---|---|
java.lang.Exception |
if this resource cannot be closed |
getConnectedToken
open fun getConnectedToken(): Session2Token?
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 fun isPlaybackActive(): Boolean
Returns whether the session's playback is active.
Return | |
---|---|
Boolean |
true if playback active. false otherwise. |
sendSessionCommand
open fun sendSessionCommand(
command: Session2Command,
args: Bundle?
): Any
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 . |