public final class AVBrowser extends Object
AVBrowserService.SystemCapability.Multimedia#MEDIA| 构造器 | 说明 |
|---|---|
AVBrowser(Context context,
ElementName name,
AVConnectionCallback callback,
PacMap options) |
A constructor used to create an
AVBrowser instance for media data provided by the media browser service. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
connect() |
Connects to the media browser service.
|
void |
disconnect() |
Disconnects from the media browser service.
|
void |
getAVElement(String mediaId,
AVElementCallback callback) |
Obtains a
AVElement instance based on the media item ID. |
AVToken |
getAVToken() |
Obtains the media session token.
|
ElementName |
getElementName() |
Obtains the
ElementName instance of the media browser service. |
PacMap |
getOptions() |
Obtains the additional media data provided by the media browser service.
|
String |
getRootMediaId() |
Obtains the ID of the root media item.
|
boolean |
isConnected() |
Checks whether the media browser service is connected.
|
void |
subscribeByParentMediaId(String parentMediaId,
AVSubscriptionCallback callback) |
Subscribes to a specified parent media item based on its ID to receive the update notifications about all its
child media items.
|
void |
subscribeByParentMediaId(String parentMediaId,
PacMap options,
AVSubscriptionCallback callback) |
Subscribes to a specified parent media item based on its ID and the parameters sent to the media browser service
to receive the update notifications about all its child media items.
|
void |
unsubscribeByParentMediaId(String parentMediaId) |
Unsubscribes from the specified parent media item.
|
void |
unsubscribeByParentMediaId(String parentMediaId,
AVSubscriptionCallback callback) |
Unsubscribes from the notification of the specified parent media item based on the callback used for the
subscription.
|
public AVBrowser(Context context, ElementName name, AVConnectionCallback callback, PacMap options)
AVBrowser instance for media data provided by the media browser service.
This constructor must be called on main thread.
context - Indicates the application context.name - Indicates the media item name consisted of the application bundle name and media browser service
name.callback - Indicates the callback that listens for the service connection status.options - Indicates a group of parameters that will be sent to the media browser service. The parameters
determine the data returned from the service. This parameter can be null.public void connect()
This is an asynchronous method. The connection result will be returned through the callback passed to the constructor.
IllegalStateException - Throws this exception if any of the following occurs:
AVBrowser has been connected to the service.AVBrowser is connecting to the service.public void disconnect()
This is an asynchronous method.
public boolean isConnected()
true if the connection is successful; returns false otherwise.public ElementName getElementName()
ElementName instance of the media browser service.ElementName instance if obtained; returns null otherwise.public String getRootMediaId()
null otherwise.public PacMap getOptions()
PacMap instance if obtained; returns null otherwise.public AVToken getAVToken()
AVToken instance if obtained; returns null
otherwise.public void getAVElement(String mediaId, AVElementCallback callback)
AVElement instance based on the media item ID. The execution
result will be returned through the passed callback.mediaId - Indicates the media item ID.callback - Indicates the callback to receive the execution result.IllegalArgumentException - Throws this exception if mediaId or callback is null.public void subscribeByParentMediaId(String parentMediaId, AVSubscriptionCallback callback)
If this method is called after the media browser service is connected, this AVBrowser instance will
subscribe to all child items of the parent media item.
If this method is called before the media browser service is connected, this AVBrowser instance will
save the parent item ID and passed callback.
After the service is connected, this AVBrowser will subscribe to all child items included in the parent
media item.
If a parent media item ID is repeatedly used for subscriptions, the latest subscription will replace the previous one.
parentMediaId - Indicates the ID of the parent media item.callback - Indicates the callback to receive the subscription result.IllegalArgumentException - Throws this exception if parentMediaId or callback is
null.public void subscribeByParentMediaId(String parentMediaId, PacMap options, AVSubscriptionCallback callback)
If this method is called after the service is connected, this AVBrowser instance will subscribe to all
child items of the parent media item.
If this method is called before the service is connected, this AVBrowser instance will save the parent
item ID and passed callback. After the service is connected,
this AVBrowser will subscribe to all child items included in the parent media item.
If a parent media item ID is repeatedly used for subscriptions with the same options parameters, the
latest subscription will replace the previous one.
parentMediaId - Indicates the ID of the parent media item.options - Indicates a group of parameters that will be sent to the service. The parameters determine the
data returned from the service.callback - Indicates the callback to receive the subscription result.IllegalArgumentException - Throws this exception if parentMediaId, options, or
callback is null.public void unsubscribeByParentMediaId(String parentMediaId)
parentMediaId - Indicates the ID of the parent media item.IllegalArgumentException - Throws this exception if parentMediaId is null.public void unsubscribeByParentMediaId(String parentMediaId, AVSubscriptionCallback callback)
This method cancels only the notification associated with the specified callback, but will not cancel other callbacks even if you have set multiple callbacks for the subscription.
parentMediaId - Indicates the ID of the parent media item.callback - Indicates the callback based on which the notification will be canceled.IllegalArgumentException - Throws this exception if parentMediaId or callback is
null.