RootSourceClient

@IviExperimental(reasons = [])
class RootSourceClient(context: Context, sourceId: SourceId, coroutineDispatcher: CoroutineDispatcher = Options.mediaCoroutineDispatcher) : SourceClient

SourceClient specialization for showing the content of the root of a media source's browsing hierarchy. It provides access to a source's categories (the top-level items used to access all available content), and can be instructed to browse through any of the available content.

If no custom media item is initially browsed to via browseTo, the contents of the first available category will be made available automatically.

Parameters

context

Android context.

sourceId

ID of the source to connect to.

coroutineDispatcher

The coroutine dispatcher to use to launch background operations. The most common are IPC requests via Binder. Defaults to the IO dispatcher.

Constructors

Link copied to clipboard
constructor(context: Context, sourceId: SourceId, coroutineDispatcher: CoroutineDispatcher = Options.mediaCoroutineDispatcher)

Properties

Link copied to clipboard

List of available top-level categories for this source. The categories could be updated over time if the source decides to do so.

Link copied to clipboard
open override val contents: LiveData<List<IviMediaItem>>

The list of IviMediaItems contained in the subscribed mediaItem. Initially empty. The contents will be updated over time if the source decides to do so.

Link copied to clipboard
open override val isAvailable: LiveData<Boolean>

Whether the source can be queried and provide content.

Link copied to clipboard
open override val isLoading: LiveData<Boolean>

Whether the source is loading content.

Link copied to clipboard

The IviMediaItem currently subscribed to. Initially empty. Can be changed to subscribe to different contents. If not changed, the client will set it to a default item: the first available category.

Link copied to clipboard
open override val rootMetadata: LiveData<Bundle?>

The client root extras. Can be used to store various values to determine source behavior.

Functions

Link copied to clipboard
fun browseTo(newMediaItem: IviMediaItem)

Load and subscribe to a new media item. The mediaItem will first be updated with the newMediaItem, then the contents will be updated with its child items. It is not necessary for the client to be connected already. This method can be called on creation to initially browse to the specified newMediaItem instead of the default.

Link copied to clipboard
open suspend override fun <T> coLaunchBrowserAction(browserAction: BrowserAction<T>): BrowserActionResult<T>

Launch a browser action.

Link copied to clipboard
open override fun connect()

Connects client to a media source to display the content. The connection is kept until disconnect is called.

Link copied to clipboard
open override fun disconnect()

Disconnects client from a media source and clears the content.

Link copied to clipboard
open override fun setErrorCallback(callback: ErrorCallback)

Set the callback where to receive notifications about error conditions.

Link copied to clipboard
open override fun setTag(tag: String)

Set a tag to identify this client in debugging logs.