SessionResult
open class SessionResult : CustomVersionedParcelable, RemoteResult
androidx.media2.session.SessionResult |
Result class to be used with ListenableFuture
for asynchronous calls between MediaSession
and MediaController
.
Summary
Constants | |
---|---|
static Int |
Result code representing that the command is successfully completed. |
Public constructors | |
---|---|
Constructor to be used by |
Public methods | |
---|---|
open Long |
Gets the completion time of the command. |
open Bundle? |
Gets the result of |
open MediaItem? |
Gets the |
open Int |
Gets the result code. |
Constants
RESULT_SUCCESS
static val RESULT_SUCCESS: Int
Result code representing that the command is successfully completed.
Interoperability: This code is also used to tell that the command was successfully sent, but the result is unknown when connected with MediaSessionCompat
or MediaControllerCompat
.
Value: 0
Public constructors
<init>
SessionResult(
resultCode: Int,
@Nullable customCommandResult: Bundle?)
Constructor to be used by MediaSession.SessionCallback#onCustomCommand( * MediaSession, MediaSession.ControllerInfo, SessionCommand, Bundle)
.
Parameters | |
---|---|
resultCode |
Int: result code |
customCommandResult |
Bundle?: custom command result. |
Public methods
getCompletionTime
open fun getCompletionTime(): Long
Gets the completion time of the command. Being more specific, it's the same as SystemClock#elapsedRealtime()
when the command completed.
Return | |
---|---|
Long |
completion time of the command |
getCustomCommandResult
@Nullable open fun getCustomCommandResult(): Bundle?
Gets the result of MediaSession#sendCustomCommand(MediaSession.ControllerInfo, SessionCommand, Bundle)
and MediaController#sendCustomCommand(SessionCommand, Bundle)
only when this object is returned by one of them.
If this object is returned by other methods, this method will be null
.
Return | |
---|---|
Bundle? |
result of sending custom command |
getMediaItem
@Nullable open fun getMediaItem(): MediaItem?
Gets the MediaItem
for which the command was executed. In other words, this is the current media item when the command completed.
Can be null
for many reasons. For examples,
- Error happened.
- Current media item was
null
at that time. - Command is irrelevant with the media item (e.g. custom command).
Return | |
---|---|
MediaItem? |
media item when the command completed. Can be null for an error, the current media item was null , or any other reason. |
getResultCode
open fun getResultCode(): Int
Gets the result code.
Return | |
---|---|
Int |
result code |
See Also
#RESULT_SUCCESS
#RESULT_ERROR_UNKNOWN
#RESULT_ERROR_INVALID_STATE
#RESULT_ERROR_BAD_VALUE
#RESULT_ERROR_PERMISSION_DENIED
#RESULT_ERROR_IO
#RESULT_INFO_SKIPPED
#RESULT_ERROR_SESSION_DISCONNECTED
#RESULT_ERROR_NOT_SUPPORTED
#RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED
#RESULT_ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED
#RESULT_ERROR_SESSION_CONCURRENT_STREAM_LIMIT
#RESULT_ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED
#RESULT_ERROR_SESSION_NOT_AVAILABLE_IN_REGION
#RESULT_ERROR_SESSION_SKIP_LIMIT_REACHED
#RESULT_ERROR_SESSION_SETUP_REQUIRED