MediaBrowserCompat
class MediaBrowserCompat
kotlin.Any | |
↳ | android.support.v4.media.MediaBrowserCompat |
Browses media content offered by a MediaBrowserServiceCompat
.
This object is not thread-safe. All calls should happen on the thread on which the browser was constructed.
All callback methods will be called from the thread on which the browser was constructed.
Summary
Nested classes |
|
---|---|
Callbacks for connection related events. |
|
abstract |
Callback for receiving the result of |
abstract |
Callback for receiving the result of |
A class with information on a single media item for use in browsing/searching media. |
|
abstract |
Callback for receiving the result of |
abstract |
Callbacks for subscription related events. |
Constants |
|
---|---|
static String |
Predefined custom action to ask the connected service to download a specific |
static String |
Predefined custom action to ask the connected service to remove the downloaded file of |
static String |
Used as a float extra field to denote the current progress during download. |
static String |
Used as a string extra field to denote the target |
static String |
Used as an int extra field to denote the page number to subscribe. |
static String |
Used as an int extra field to denote the number of media items in a page. |
Public constructors |
|
---|---|
<init>(context: Context!, serviceComponent: ComponentName!, callback: MediaBrowserCompat.ConnectionCallback!, rootHints: Bundle!) Creates a media browser for the specified media browse service. |
Public methods |
|
---|---|
Unit |
connect() Connects to the media browse service. |
Unit |
Disconnects from the media browse service. |
Bundle? |
Gets any extras for the media service. |
Unit |
getItem(@NonNull mediaId: String, @NonNull cb: MediaBrowserCompat.ItemCallback) Retrieves a specific |
String |
getRoot() Gets the root id. |
ComponentName |
Gets the service component that the media browser is connected to. |
MediaSessionCompat.Token |
Gets the media session token associated with the media browser. |
Boolean |
Returns whether the browser is connected to the service. |
Unit |
search(@NonNull query: String, extras: Bundle!, @NonNull callback: MediaBrowserCompat.SearchCallback) Searches |
Unit |
sendCustomAction(@NonNull action: String, extras: Bundle!, @Nullable callback: MediaBrowserCompat.CustomActionCallback?) Sends a custom action to the connected service. |
Unit |
subscribe(@NonNull parentId: String, @NonNull callback: MediaBrowserCompat.SubscriptionCallback) Queries for information about the media items that are contained within the specified id and subscribes to receive updates when they change. |
Unit |
subscribe(@NonNull parentId: String, @NonNull options: Bundle, @NonNull callback: MediaBrowserCompat.SubscriptionCallback) Queries with service-specific arguments for information about the media items that are contained within the specified id and subscribes to receive updates when they change. |
Unit |
unsubscribe(@NonNull parentId: String) Unsubscribes for changes to the children of the specified media id. |
Unit |
unsubscribe(@NonNull parentId: String, @NonNull callback: MediaBrowserCompat.SubscriptionCallback) Unsubscribes for changes to the children of the specified media id. |
Constants
CUSTOM_ACTION_DOWNLOAD
static val CUSTOM_ACTION_DOWNLOAD: String
Predefined custom action to ask the connected service to download a specific MediaItem
for offline playback. The id of the media item must be passed in an extra bundle. The download progress might be delivered to the browser via CustomActionCallback#onProgressUpdate
.
Value: "android.support.v4.media.action.DOWNLOAD"
CUSTOM_ACTION_REMOVE_DOWNLOADED_FILE
static val CUSTOM_ACTION_REMOVE_DOWNLOADED_FILE: String
Predefined custom action to ask the connected service to remove the downloaded file of MediaItem
by the download
action. The id of the media item must be passed in an extra bundle.
Value: "android.support.v4.media.action.REMOVE_DOWNLOADED_FILE"
EXTRA_DOWNLOAD_PROGRESS
static val EXTRA_DOWNLOAD_PROGRESS: String
Used as a float extra field to denote the current progress during download. The value of this field must be a float number within [0.0, 1.0].
Value: "android.media.browse.extra.DOWNLOAD_PROGRESS"
EXTRA_MEDIA_ID
static val EXTRA_MEDIA_ID: String
Used as a string extra field to denote the target MediaItem
.
Value: "android.media.browse.extra.MEDIA_ID"
EXTRA_PAGE
static val EXTRA_PAGE: String
Used as an int extra field to denote the page number to subscribe. The value of EXTRA_PAGE
should be greater than or equal to 0.
Value: "android.media.browse.extra.PAGE"
EXTRA_PAGE_SIZE
static val EXTRA_PAGE_SIZE: String
Used as an int extra field to denote the number of media items in a page. The value of EXTRA_PAGE_SIZE
should be greater than or equal to 1.
Value: "android.media.browse.extra.PAGE_SIZE"
Public constructors
<init>
MediaBrowserCompat(context: Context!, serviceComponent: ComponentName!, callback: MediaBrowserCompat.ConnectionCallback!, rootHints: Bundle!)
Creates a media browser for the specified media browse service.
Parameters | |
---|---|
context |
Context!: The context. |
serviceComponent |
Context!: The component name of the media browse service. |
callback |
Context!: The connection callback. |
rootHints |
Context!: An optional bundle of service-specific arguments to send to the media browse service when connecting and retrieving the root id for browsing, or null if none. The contents of this bundle may affect the information returned when browsing. |
Public methods
connect
fun connect(): Unit
Connects to the media browse service. Internally, it binds to the service.
The connection callback specified in the constructor will be invoked when the connection completes or fails.
disconnect
fun disconnect(): Unit
Disconnects from the media browse service. After this, no more callbacks will be received.