ILifecycle, Contextpublic abstract class AVBrowserService extends Ability
The media browser service enables your application to browse and play media items from another application.
To extend this class, you need to configure the config.json for your project with "actions" in
the "skills" attribute set to SERVICE_ACTION.
Example code:
{
"name": ".MyAVBrowserService",
"skills": [
{
"actions": [
"action.media.browse.AVBrowserService"
]
}
],
"type": "service",
}
SystemCapability.Multimedia#MEDIAAbility.LayoutParamsHelper, Ability.WindowAttributeHelper| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static String |
SERVICE_ACTION |
Indicates the action name of the media browser service.
|
FORM_INVISIBLE, FORM_VISIBLECONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESOUCE_ONLY, CONTEXT_RESTRICTED, MODE_APPEND, MODE_PRIVATE| 构造器 | 说明 |
|---|---|
AVBrowserService() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
AVToken |
getAVToken() |
Obtains the token for the session between the
AVBrowser and this AVBrowserService. |
PacMap |
getBrowserOptions() |
Obtains the media browser service parameters set when the
AVBrowser connects to this AVBrowserService. |
AVCallerUserInfo |
getCallerUserInfo() |
Obtains information about the remote user who sends the current request.
|
void |
notifyAVElementListUpdated(String parentMediaId) |
Notifies all connected
AVBrowser instances that the child media items of the current parent media item
have changed. |
void |
notifyAVElementListUpdated(String parentMediaId,
PacMap options) |
Notifies all connected
AVBrowser instances that the child media items of the current parent media item
have changed, with media browser service parameters set. |
abstract AVBrowserRoot |
onGetRoot(String callerPackageName,
int clientUid,
PacMap options) |
Called after the
AVBrowser#connect() method to return the information about the root item. |
abstract void |
onLoadAVElement(String mediaId,
AVBrowserResult result) |
Called after
AVBrowser#getAVElement to obtain the AVBrowserResult instance of the AVElement specified by the media item ID. |
abstract void |
onLoadAVElementList(String parentMediaId,
AVBrowserResult result) |
Called after
AVBrowser#subscribeByParentMediaId or notifyAVElementListUpdated(java.lang.String) to return the
requested AVBrowserResult instance, including a list of AVElement instances for child media
items. |
abstract void |
onLoadAVElementList(String parentMediaId,
AVBrowserResult result,
PacMap options) |
Called after
AVBrowser#subscribeByParentMediaId or notifyAVElementListUpdated(java.lang.String) to return the
requested AVBrowserResult instance and media browser service parameters. |
protected void |
onStart(Intent intent) |
Called back when an ability is started for initialization (it can be called only once in the entire lifecycle of
an ability).
|
void |
setAVToken(AVToken token) |
Sets the token for the session between the
AVBrowser and this AVBrowserService. |
addActionRoute, batchInsert, call, cancelBackgroundRunning, connectAbility, continueAbility, continueAbility, continueAbilityReversibly, continueAbilityReversibly, createPipeFile, delete, denormalizeUri, disconnectAbility, dispatchAccessibilityEventInfo, executeBatch, executeOperation, findComponentById, getAbilityName, getAbilityPackage, getAdmissionTransitionConcurEnabled, getAdmissionTransitionObject, getAVController, getBackTransitionConcurEnabled, getBackTransitionObject, getContinuationRegisterManager, getContinuationState, getCurrentFocus, getFileTypes, getIntent, getLayoutParams, getLifecycle, getOriginalDeviceId, getQuitTransitionObject, getReadmissionTransitionObject, getSharedItemAdmissionTransitionObject, getSharedItemBackTransitionObject, getSharedItemQuitTransitionObject, getSharedItemReadmissionTransitionObject, getState, getType, getVolumeTypeAdjustedByKey, getWindow, hasWindowFocus, insert, isTemporary, isTerminating, keepBackgroundRunning, normalizeUri, onAbilityResult, onAcquireFormState, onActive, onBackground, onBackPressed, onCastTempForm, onCommand, onCommand, onConfigurationUpdated, onConnect, onCreateForm, onCreateForm, onDeleteForm, onDeleteForm, onDisconnect, onEventDispatch, onEventNotify, onForeground, onHotkeyTriggered, onInactive, onInitialized, onKeyDown, onKeyPressAndHold, onKeyUp, onLeaveForeground, onMemoryLevel, onMissionDeleted, onNewDescription, onNewIntent, onOrientationChanged, onPostActive, onPostStart, onReconnect, onRequestPermissionsFromUserResult, onRestoreAbilityState, onSaveAbilityState, onSetCaller, onStop, onStoreDataWhenConfigChange, onTopActiveAbilityChanged, onTouchEvent, onTriggerFormEvent, onTriggerFormEvent, onUnloadForm, onUpdateForm, onUpdateForm, onWindowFocusChanged, openFile, openRawFile, parsePredictionArgsReference, parseValuesBucketReference, postTask, query, reload, reverseContinueAbility, setAbilitySliceAnimator, setAdmissionTransitionConcurEnabled, setAdmissionTransitionObject, setAVController, setBackTransitionConcurEnabled, setBackTransitionObject, setFormNextRefreshTime, setIntent, setIsAmbientMode, setLayoutParams, setMainRoute, setQuitTransitionObject, setReadmissionTransitionObject, setResult, setSharedItemAdmissionTransitionObject, setSharedItemBackTransitionObject, setSharedItemQuitTransitionObject, setSharedItemReadmissionTransitionObject, setSwipeToDismiss, setUIContent, setUIContent, setVolumeTypeAdjustedByKey, setWindowBackgroundColor, shutdown, startAbility, startAbility, startAbility, startAbility, startAbilityForResult, startAbilityForResult, startAssistAbility, stopAbility, stopAssistAbility, supportHighPerformanceUI, terminateAbility, update, updateForm, updateForm, updateForm, updateFormattachBaseContext, canRequestPermission, compelVerifyCallerPermission, compelVerifyCallerUriPermission, compelVerifyPermission, compelVerifyPermission, compelVerifyUriPermission, compelVerifyUriPermission, compelVerifyUriPermission, createBundleContext, createParallelTaskDispatcher, createSerialTaskDispatcher, deleteFile, displayUnlockMissionMessage, getAbilityInfo, getAbilityManager, getAbilityPackageContext, getApplicationContext, getApplicationInfo, getAppType, getBundleCodePath, getBundleManager, getBundleName, getBundleResourcePath, getCacheDir, getCaller, getCallingAbility, getCallingBundle, getClassloader, getCodeCacheDir, getColor, getColorMode, getContext, getDatabaseDir, getDataDir, getDir, getDisplayOrientation, getDistributedDir, getElementName, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getGlobalTaskDispatcher, getHapModuleInfo, getIntArray, getLastStoredDataWhenConfigChanged, getLocalClassName, getMainTaskDispatcher, getNoBackupFilesDir, getPattern, getPreferencesDir, getProcessInfo, getProcessName, getResourceManager, getResourceManager, getString, getString, getStringArray, getTheme, getThemeId, getUITaskDispatcher, init, isCredentialEncryptedStorage, isDeviceEncryptedStorage, isUpdatingConfigurations, lockMission, printDrawnCompleted, requestPermissionsFromUser, restart, setColorMode, setDisplayOrientation, setPattern, setShowOnLockScreen, setTheme, setTransitionAnimation, setWakeUpScreen, startAbilities, startAbility, startAbility, startAbility, switchToCredentialEncryptedStorageContext, switchToDeviceEncryptedStorageContext, terminateAbility, terminateAbilityResult, unlockMission, verifyCallingOrSelfPermission, verifyCallingPermission, verifyPermission, verifySelfPermissionprotected void onStart(Intent intent)
AbilityMost initialization operations should be performed by calling this method. For example, you can use the
current method to call Ability.setMainRoute(java.lang.String) and
Ability.addActionRoute(java.lang.String,java.lang.String) to set the main router and action router for a Page ability.
public abstract AVBrowserRoot onGetRoot(String callerPackageName, int clientUid, PacMap options)
AVBrowser#connect() method to return the information about the root item.callerPackageName - Indicates the bundle name of the application.clientUid - Indicates the user ID of the application.options - Indicates optional parameters sent to the media browser service when the AVBrowser
instance is created.AVBrowserRoot instance; returns null if your application does not have
permission to access the root item.public abstract void onLoadAVElementList(String parentMediaId, AVBrowserResult result)
AVBrowser#subscribeByParentMediaId or notifyAVElementListUpdated(java.lang.String) to return the
requested AVBrowserResult instance, including a list of AVElement instances for child media
items.parentMediaId - Indicates the ID of the parent media item in the AVBrowserResult instance.result - Indicates the AVBrowserResult instance.public abstract void onLoadAVElementList(String parentMediaId, AVBrowserResult result, PacMap options)
AVBrowser#subscribeByParentMediaId or notifyAVElementListUpdated(java.lang.String) to return the
requested AVBrowserResult instance and media browser service parameters. The AVBrowserResult
includes a list of AVElement instances for child media items.parentMediaId - Indicates the ID of the parent media item in the AVBrowserResult instance.result - Indicates the AVBrowserResult instance.options - Indicates media browser service parameters.public abstract void onLoadAVElement(String mediaId, AVBrowserResult result)
AVBrowser#getAVElement to obtain the AVBrowserResult instance of the AVElement specified by the media item ID.mediaId - Indicates the media item ID.result - Indicates the AVBrowserResult instance of the media item.public AVToken getAVToken()
AVBrowser and this AVBrowserService.null if the session is not created or has been destroyed.public void setAVToken(AVToken token)
AVBrowser and this AVBrowserService.token - Indicates the session token.IllegalArgumentException - Throws this exception if token is null.IllegalStateException - Throws this exception if this method is called repeatedly to set the
token.public final PacMap getBrowserOptions()
AVBrowser connects to this AVBrowserService.IllegalStateException - Throw this exception if this method is not called in the onGetRoot(java.lang.String, int, ohos.utils.PacMap), onLoadAVElementList(java.lang.String, ohos.media.common.sessioncore.AVBrowserResult), or onLoadAVElement(java.lang.String, ohos.media.common.sessioncore.AVBrowserResult) method.public final AVCallerUserInfo getCallerUserInfo()
public void notifyAVElementListUpdated(String parentMediaId)
AVBrowser instances that the child media items of the current parent media item
have changed.parentMediaId - Indicates the ID of the parent media item.IllegalArgumentException - Throws this exception if parentMediaId is null.public void notifyAVElementListUpdated(String parentMediaId, PacMap options)
AVBrowser instances that the child media items of the current parent media item
have changed, with media browser service parameters set.parentMediaId - Indicates the ID of the parent media item.options - Indicates media browser service parameters.IllegalArgumentException - Throws this exception if parentMediaId or {code options} is
null.