LibraryResult

open class LibraryResult : CustomVersionedParcelable, RemoteResult
androidx.media2.session.LibraryResult

Result class to be used with ListenableFuture for asynchronous calls between MediaLibraryService.MediaLibrarySession and MediaBrowser.

Summary

Public constructors

<init>(resultCode: Int)

Constructor only with the result code.

<init>(resultCode: Int, @Nullable item: MediaItem?, @Nullable params: MediaLibraryService.LibraryParams?)

Constructor with the result code and a media item.

<init>(resultCode: Int, @Nullable items: MutableList<MediaItem!>?, @Nullable params: MediaLibraryService.LibraryParams?)

Constructor with the result code and a list of media items.

Public methods

open Long

Gets the completion time of the command.

open MediaLibraryService.LibraryParams?

Gets the library params

open MediaItem?

Gets the media item.

open MutableList<MediaItem!>?

Gets the list of media item.

open Int

Gets the result code.

Public constructors

<init>

LibraryResult(resultCode: Int)

Constructor only with the result code.

For success, use other constructor that you can also return the result.

Parameters
resultCode Int: result code

<init>

LibraryResult(resultCode: Int, @Nullable item: MediaItem?, @Nullable params: MediaLibraryService.LibraryParams?)

Constructor with the result code and a media item.

Parameters
resultCode Int: result code
item Int: a media item. Can be null for error
params Int: optional library params to describe the returned media item

<init>

LibraryResult(resultCode: Int, @Nullable items: MutableList<MediaItem!>?, @Nullable params: MediaLibraryService.LibraryParams?)

Constructor with the result code and a list of media items.

Parameters
resultCode Int: result code
items Int: list of media items. Can be null for error
params Int: optional library params to describe the returned list of media items.

Public methods

getCompletionTime

open fun getCompletionTime(): Long

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

Return
Long: completion time of the command

getLibraryParams

@Nullable open fun getLibraryParams(): MediaLibraryService.LibraryParams?

Gets the library params

Return
MediaLibraryService.LibraryParams?: library params.

getMediaItem

@Nullable open fun getMediaItem(): MediaItem?

Gets the media item.

Can be null if an error happened or the command doesn't return a media item.

Return
MediaItem?: media item

getMediaItems

@Nullable open fun getMediaItems(): MutableList<MediaItem!>?

Gets the list of media item.

Can be null if an error happened or the command doesn't return a list of media items.

Return
MutableList<MediaItem!>?: list of media item