SessionResult

Added in 1.0.0
Deprecated in 1.3.0

public class SessionResult implements VersionedParcelable


Result class to be used with ListenableFuture for asynchronous calls between and MediaController.

Summary

Constants

static final int

Result code representing that the authentication has expired.

static final int

Result code representing that too many concurrent streams are detected.

static final int

Result code representing that the session and controller were disconnected.

static final int

Result code representing that the content is blocked due to being regionally unavailable.

static final int

Result code representing that the content is blocked due to parental controls.

static final int

Result code representing that a premium account is required.

static final int

Result code representing that the session needs user's manual intervention.

static final int

Result code representing that the application cannot skip any more because the skip limit is reached.

static final int

Result code representing that the command is successfully completed.

Public constructors

SessionResult(int resultCode, @Nullable Bundle customCommandResult)

Constructor to be used by onCustomCommand.

Public methods

long

Gets the completion time of the command.

@Nullable Bundle

Gets the result of sendCustomCommand and sendCustomCommand only when this object is returned by one of them.

@Nullable MediaItem

Gets the MediaItem for which the command was executed.

int

Gets the result code.

Constants

RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED

Added in 1.0.0
public static final int RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED = -102

Result code representing that the authentication has expired.

RESULT_ERROR_SESSION_CONCURRENT_STREAM_LIMIT

Added in 1.0.0
public static final int RESULT_ERROR_SESSION_CONCURRENT_STREAM_LIMIT = -104

Result code representing that too many concurrent streams are detected.

RESULT_ERROR_SESSION_DISCONNECTED

Added in 1.0.0
public static final int RESULT_ERROR_SESSION_DISCONNECTED = -100

Result code representing that the session and controller were disconnected.

RESULT_ERROR_SESSION_NOT_AVAILABLE_IN_REGION

Added in 1.0.0
public static final int RESULT_ERROR_SESSION_NOT_AVAILABLE_IN_REGION = -106

Result code representing that the content is blocked due to being regionally unavailable.

RESULT_ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED

Added in 1.0.0
public static final int RESULT_ERROR_SESSION_PARENTAL_CONTROL_RESTRICTED = -105

Result code representing that the content is blocked due to parental controls.

RESULT_ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED

Added in 1.0.0
public static final int RESULT_ERROR_SESSION_PREMIUM_ACCOUNT_REQUIRED = -103

Result code representing that a premium account is required.

RESULT_ERROR_SESSION_SETUP_REQUIRED

Added in 1.0.0
public static final int RESULT_ERROR_SESSION_SETUP_REQUIRED = -108

Result code representing that the session needs user's manual intervention.

RESULT_ERROR_SESSION_SKIP_LIMIT_REACHED

Added in 1.0.0
public static final int RESULT_ERROR_SESSION_SKIP_LIMIT_REACHED = -107

Result code representing that the application cannot skip any more because the skip limit is reached.

RESULT_SUCCESS

Added in 1.0.0
Deprecated in 1.3.0
public static final int RESULT_SUCCESS = 0

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.

Public constructors

SessionResult

Added in 1.0.0
Deprecated in 1.3.0
public SessionResult(int resultCode, @Nullable Bundle customCommandResult)

Constructor to be used by onCustomCommand.

Parameters
int resultCode

result code

@Nullable Bundle customCommandResult

custom command result.

Public methods

getCompletionTime

Added in 1.0.0
Deprecated in 1.3.0
public long getCompletionTime()

Gets the completion time of the command. Being more specific, it's the same as elapsedRealtime when the command completed.

Returns
long

completion time of the command

getCustomCommandResult

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable Bundle getCustomCommandResult()

Gets the result of sendCustomCommand and sendCustomCommand only when this object is returned by one of them.

If this object is returned by other methods, this method will be null.

Returns
@Nullable Bundle

result of sending custom command

getMediaItem

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable MediaItem getMediaItem()

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).
Returns
@Nullable MediaItem

media item when the command completed. Can be null for an error, the current media item was null, or any other reason.