SessionPlayer.PlayerResult

public static class SessionPlayer.PlayerResult
extends Object

java.lang.Object
   ↳ androidx.media2.common.SessionPlayer.PlayerResult


Result class of the asynchronous APIs.

Subclass may extend this class for providing more result and/or custom result code. For the custom result code, follow the convention below to avoid potential code duplication.

  • Predefined error code: Negative integers greater than -100. (i.e. -100 < code < 0)
  • Custom error code: Negative integers equal to or less than -1000. (i.e. code < -1000)
  • Predefined info code: Positive integers less than 100. (i.e. 0 < code < 100)
  • Custom Info code: Positive integers equal to or greater than 1000. (i.e. code > +1000)

Summary

Constants

int RESULT_ERROR_BAD_VALUE

Result code representing that an argument is illegal.

int RESULT_ERROR_INVALID_STATE

Result code representing that the command cannot be completed because the current state is not valid for the command.

int RESULT_ERROR_IO

Result code representing a file or network related command error.

int RESULT_ERROR_NOT_SUPPORTED

Result code representing that the command is not supported nor implemented.

int RESULT_ERROR_PERMISSION_DENIED

Result code representing that the command is not allowed.

int RESULT_ERROR_UNKNOWN

Result code represents that call is ended with an unknown error.

int RESULT_INFO_SKIPPED

Result code representing that the command is skipped or canceled.

int RESULT_SUCCESS

Result code representing that the command is successfully completed.

Public constructors

SessionPlayer.PlayerResult(int resultCode, MediaItem item)

Constructor that uses the current system clock as the completion time.

Public methods

long getCompletionTime()

Gets the completion time of the command.

MediaItem getMediaItem()

Gets the MediaItem for which the command was executed.

int getResultCode()

Gets the result code.

Inherited methods

Constants

RESULT_ERROR_BAD_VALUE

public static final int RESULT_ERROR_BAD_VALUE

Result code representing that an argument is illegal.

Constant Value: -3 (0xfffffffd)

RESULT_ERROR_INVALID_STATE

public static final int RESULT_ERROR_INVALID_STATE

Result code representing that the command cannot be completed because the current state is not valid for the command.

Constant Value: -2 (0xfffffffe)

RESULT_ERROR_IO

public static final int RESULT_ERROR_IO

Result code representing a file or network related command error.

Constant Value: -5 (0xfffffffb)

RESULT_ERROR_NOT_SUPPORTED

public static final int RESULT_ERROR_NOT_SUPPORTED

Result code representing that the command is not supported nor implemented.

Constant Value: -6 (0xfffffffa)

RESULT_ERROR_PERMISSION_DENIED

public static final int RESULT_ERROR_PERMISSION_DENIED

Result code representing that the command is not allowed.

Constant Value: -4 (0xfffffffc)

RESULT_ERROR_UNKNOWN

public static final int RESULT_ERROR_UNKNOWN

Result code represents that call is ended with an unknown error.

Constant Value: -1 (0xffffffff)

RESULT_INFO_SKIPPED

public static final int RESULT_INFO_SKIPPED

Result code representing that the command is skipped or canceled. For an example, a seek command can be skipped if it is followed by another seek command.

Constant Value: 1 (0x00000001)

RESULT_SUCCESS

public static final int RESULT_SUCCESS

Result code representing that the command is successfully completed.

Constant Value: 0 (0x00000000)

Public constructors

SessionPlayer.PlayerResult

public SessionPlayer.PlayerResult (int resultCode, 
                MediaItem item)

Constructor that uses the current system clock as the completion time.

Parameters
resultCode int: result code. Recommends to use the standard code defined here.

item MediaItem: media item when the command completed

Public methods

getCompletionTime

public long getCompletionTime ()

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

Returns
long completion time of the command

getMediaItem

public MediaItem getMediaItem ()

Gets the MediaItem for which the command was executed. In other words, this is the item sent as an argument of the command if any, otherwise the current media item when the command completed.

Returns
MediaItem media item when the command completed. Can be null for an error, or the current media item was null.

getResultCode

public int getResultCode ()

Gets the result code.

Subclass of the SessionPlayer may have defined customized extra code other than codes defined here. Check the documentation of the class that you're interested in.

Returns
int result code.