LibraryResult
public final class LibraryResult<V>
A result to be used with ListenableFuture for asynchronous calls between MediaLibraryService.MediaLibrarySession and MediaBrowser.
Summary
Constants |
|
|---|---|
static final int |
Result code representing that an argument is illegal. |
static final int |
Result code representing that the command cannot be completed because the current state is not valid for the command. |
static final int |
RESULT_ERROR_IO = -5Result code representing that a file or network related error happened. |
static final int |
Result code representing that the command is not supported. |
static final int |
Result code representing that the command is not allowed. |
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_ERROR_UNKNOWN = -1Result code representing that the command is ended with an unknown error. |
static final int |
Result code representing that the command is skipped. |
static final int |
RESULT_SUCCESS = 0Result code representing that the command is successfully completed. |
Public fields |
|
|---|---|
final long |
The completion time of the command in milliseconds. |
final @Nullable MediaLibraryService.LibraryParams |
The optional parameters. |
final int |
The |
final @Nullable SessionError |
The optional session error. |
final @Nullable V |
The value of this result. |
Public methods |
|
|---|---|
static LibraryResult<MediaItem> |
@UnstableApiRestores a |
static LibraryResult<ImmutableList<MediaItem>> |
@UnstableApiRestores a |
static LibraryResult<Object> |
@UnstableApiRestores a |
static LibraryResult<Void> |
@UnstableApiRestores a |
static LibraryResult<V> |
<V> ofError(@LibraryResult.Code int errorCode)Creates an instance with an unsuccessful |
static LibraryResult<V> |
@UnstableApiCreates an instance with a |
static LibraryResult<V> |
<V> ofError(Creates an instance with an unsuccessful |
static LibraryResult<V> |
@UnstableApiCreates an instance with a |
static LibraryResult<MediaItem> |
ofItem(Creates an instance with a media item and |
static LibraryResult<ImmutableList<MediaItem>> |
ofItemList(Creates an instance with a list of media items and |
static LibraryResult<Void> |
ofVoid()Creates an instance with |
static LibraryResult<Void> |
Creates an instance with |
Bundle |
Constants
RESULT_ERROR_BAD_VALUE
public static final int RESULT_ERROR_BAD_VALUE = -3
Result code representing that an argument is illegal.
RESULT_ERROR_INVALID_STATE
public static final int RESULT_ERROR_INVALID_STATE = -2
Result code representing that the command cannot be completed because the current state is not valid for the command.
RESULT_ERROR_IO
public static final int RESULT_ERROR_IO = -5
Result code representing that a file or network related error happened.
RESULT_ERROR_NOT_SUPPORTED
public static final int RESULT_ERROR_NOT_SUPPORTED = -6
Result code representing that the command is not supported.
RESULT_ERROR_PERMISSION_DENIED
public static final int RESULT_ERROR_PERMISSION_DENIED = -4
Result code representing that the command is not allowed.
RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED
public static final int RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED = -102
Result code representing that the authentication has expired.
RESULT_ERROR_SESSION_CONCURRENT_STREAM_LIMIT
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
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
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
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
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
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
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_ERROR_UNKNOWN
public static final int RESULT_ERROR_UNKNOWN = -1
Result code representing that the command is ended with an unknown error.
RESULT_INFO_SKIPPED
public static final int RESULT_INFO_SKIPPED = 1
Result code representing that the command is skipped.
RESULT_SUCCESS
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
android.support.v4.media.session.MediaSessionCompat or
android.support.v4.media.session.MediaControllerCompat.
Public fields
completionTimeMs
public final long completionTimeMs
The completion time of the command in milliseconds. It's the same as elapsedRealtime when the command is completed.
sessionError
@UnstableApi
public final @Nullable SessionError sessionError
The optional session error.
value
public final @Nullable V value
The value of this result. Will be null if resultCode is not RESULT_SUCCESS.
Public methods
fromItemBundle
@UnstableApi
public static LibraryResult<MediaItem> fromItemBundle(Bundle bundle)
Restores a LibraryResult<MediaItem> from a Bundle.
fromItemListBundle
@UnstableApi
public static LibraryResult<ImmutableList<MediaItem>> fromItemListBundle(Bundle bundle)
Restores a LibraryResult<ImmutableList<MediaItem> from a Bundle.
fromUnknownBundle
@UnstableApi
public static LibraryResult<Object> fromUnknownBundle(Bundle bundle)
Restores a LibraryResult with unknown value type from a Bundle.
fromVoidBundle
@UnstableApi
public static LibraryResult<Void> fromVoidBundle(Bundle bundle)
Restores a LibraryResult<Void> from a Bundle.
ofError
public static LibraryResult<V> <V> ofError(@LibraryResult.Code int errorCode)
Creates an instance with an unsuccessful result code.
errorCode must not be RESULT_SUCCESS.
Note: This method will be deprecated when ofError is promoted to stable API status.
| Parameters | |
|---|---|
@LibraryResult.Code int errorCode |
The error code. |
ofError
@UnstableApi
public static LibraryResult<V> <V> ofError(SessionError sessionError)
Creates an instance with a SessionError to describe the error. The resultCode is taken from code.
| Parameters | |
|---|---|
SessionError sessionError |
The |
ofError
public static LibraryResult<V> <V> ofError(
@LibraryResult.Code int errorCode,
@Nullable MediaLibraryService.LibraryParams params
)
Creates an instance with an unsuccessful result code and LibraryParams to describe the error.
errorCode must not be RESULT_SUCCESS.
Note: This method will be deprecated when ofError is promoted to stable API status.
| Parameters | |
|---|---|
@LibraryResult.Code int errorCode |
The error code. |
@Nullable MediaLibraryService.LibraryParams params |
The optional parameters to describe the error. |
ofError
@UnstableApi
public static LibraryResult<V> <V> ofError(
SessionError sessionError,
MediaLibraryService.LibraryParams params
)
Creates an instance with a SessionError to describe the error, and the parameters sent by the browser. The resultCode is taken from code.
| Parameters | |
|---|---|
SessionError sessionError |
The |
MediaLibraryService.LibraryParams params |
The |
ofItem
public static LibraryResult<MediaItem> ofItem(
MediaItem item,
@Nullable MediaLibraryService.LibraryParams params
)
Creates an instance with a media item and resultCode==RESULT_SUCCESS.
The mediaMetadata must specify isBrowsable and isPlayable fields.
| Parameters | |
|---|---|
MediaItem item |
The media item. |
@Nullable MediaLibraryService.LibraryParams params |
The optional parameters to describe the media item. |
ofItemList
public static LibraryResult<ImmutableList<MediaItem>> ofItemList(
List<MediaItem> items,
@Nullable MediaLibraryService.LibraryParams params
)
Creates an instance with a list of media items and resultCode==RESULT_SUCCESS.
The mediaMetadata of each item in the list must specify isBrowsable and isPlayable fields.
| Parameters | |
|---|---|
List<MediaItem> items |
The list of media items. |
@Nullable MediaLibraryService.LibraryParams params |
The optional parameters to describe the list of media items. |
ofVoid
public static LibraryResult<Void> ofVoid()
Creates an instance with resultCode==RESULT_SUCCESS.
ofVoid
public static LibraryResult<Void> ofVoid(@Nullable MediaLibraryService.LibraryParams params)
Creates an instance with resultCode==RESULT_SUCCESS and optional params.