MediaBrowser
public
class
MediaBrowser
extends MediaController
| java.lang.Object | ||
| ↳ | androidx.media2.session.MediaController | |
| ↳ | androidx.media2.session.MediaBrowser | |
Browses media content offered by a MediaLibraryService.
Summary
Nested classes | |
|---|---|
class |
MediaBrowser.BrowserCallback
Callback to listen events from |
class |
MediaBrowser.Builder
Builder for |
Public methods | |
|---|---|
ListenableFuture<LibraryResult>
|
getChildren(String parentId, int page, int pageSize, MediaLibraryService.LibraryParams params)
Gets the list of children under the parent. |
ListenableFuture<LibraryResult>
|
getItem(String mediaId)
Gets the media item with the given media id. |
ListenableFuture<LibraryResult>
|
getLibraryRoot(MediaLibraryService.LibraryParams params)
Gets the library root. |
ListenableFuture<LibraryResult>
|
getSearchResult(String query, int page, int pageSize, MediaLibraryService.LibraryParams params)
Gets the search result from the library service. |
ListenableFuture<LibraryResult>
|
search(String query, MediaLibraryService.LibraryParams params)
Sends a search request to the library service. |
ListenableFuture<LibraryResult>
|
subscribe(String parentId, MediaLibraryService.LibraryParams params)
Subscribes to a parent id for the change in its children. |
ListenableFuture<LibraryResult>
|
unsubscribe(String parentId)
Unsubscribes for changes to the children of the parent, which was previously subscribed with
|
Inherited methods | |
|---|---|
Public methods
getChildren
public ListenableFuture<LibraryResult> getChildren (String parentId, int page, int pageSize, MediaLibraryService.LibraryParams params)
Gets the list of children under the parent.
If it's successfully completed, LibraryResult.getMediaItems() will return the list
of children.
| Parameters | |
|---|---|
parentId |
String: non-empty parent id for getting the children |
page |
int: page number to get the result. Starts from 0 |
pageSize |
int: page size. Should be greater than or equal to 1Value is 1 or greater. |
params |
MediaLibraryService.LibraryParams: library params |
| Returns | |
|---|---|
ListenableFuture<LibraryResult> |
|
See also:
getItem
public ListenableFuture<LibraryResult> getItem (String mediaId)
Gets the media item with the given media id.
If it's successfully completed, LibraryResult.getMediaItem() will return the media
item.
| Parameters | |
|---|---|
mediaId |
String: non-empty media id for specifying the item |
| Returns | |
|---|---|
ListenableFuture<LibraryResult> |
|
See also:
getLibraryRoot
public ListenableFuture<LibraryResult> getLibraryRoot (MediaLibraryService.LibraryParams params)
Gets the library root.
If it's successfully completed, LibraryResult.getMediaItem() will return the library
root.
| Parameters | |
|---|---|
params |
MediaLibraryService.LibraryParams: library params getting root |
| Returns | |
|---|---|
ListenableFuture<LibraryResult> |
|
See also:
getSearchResult
public ListenableFuture<LibraryResult> getSearchResult (String query, int page, int pageSize, MediaLibraryService.LibraryParams params)
Gets the search result from the library service.
If it's successfully completed, LibraryResult.getMediaItems() will return the search
result.
| Parameters | |
|---|---|
query |
String: non-empty search query that you've specified with
search(String, LibraryParams). |
page |
int: page number to get search result. Starts from 0 |
pageSize |
int: page size. Should be greater or equal to 1Value is 1 or greater. |
params |
MediaLibraryService.LibraryParams: library params |
| Returns | |
|---|---|
ListenableFuture<LibraryResult> |
|
See also:
search
public ListenableFuture<LibraryResult> search (String query, MediaLibraryService.LibraryParams params)
Sends a search request to the library service.
Returned LibraryResult will only tell whether the attempt to search was successful.
For getting the search result, wait for
MediaBrowser.BrowserCallback.onSearchResultChanged(MediaBrowser, String, int, LibraryParams)
being called and call getSearchResult(String, int, int, LibraryParams)}
for getting the result.
| Parameters | |
|---|---|
query |
String: non-empty search query |
params |
MediaLibraryService.LibraryParams: library params |
| Returns | |
|---|---|
ListenableFuture<LibraryResult> |
|
subscribe
public ListenableFuture<LibraryResult> subscribe (String parentId, MediaLibraryService.LibraryParams params)
Subscribes to a parent id for the change in its children. When there's a change,
MediaBrowser.BrowserCallback.onChildrenChanged(MediaBrowser, String, int, LibraryParams) will be
called with the library params. You should call
getChildren(String, int, int, LibraryParams)
to get the items under the parent.
| Parameters | |
|---|---|
parentId |
String: non-empty parent id |
params |
MediaLibraryService.LibraryParams: library params
|
| Returns | |
|---|---|
ListenableFuture<LibraryResult> |
|
unsubscribe
public ListenableFuture<LibraryResult> unsubscribe (String parentId)
Unsubscribes for changes to the children of the parent, which was previously subscribed with
subscribe(String, LibraryParams).
This unsubscribes all previous subscriptions with the parent id, regardless of the library param that was previously sent to the library service.
| Parameters | |
|---|---|
parentId |
String: non-empty parent id
|
| Returns | |
|---|---|
ListenableFuture<LibraryResult> |
|
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-06-24 UTC.