openharmony 鸿蒙 arkts-apis-photoAccessHelper-i

2026-08-25 浏览 (1)

Interfaces (Others)

NOTE

The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { photoAccessHelper } from '@kit.MediaLibraryKit';

MediaChangeRequest11+

Media change request, which is the parent class of the asset change request and album change request.

NOTE

MediaChangeRequest takes effect only after applyChanges is called.

Attributes

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since API version 23.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
comment23+stringYesNoUsed to verify the MediaChangeRequest type.
If a class (such as MediaAssetChangeRequest or MediaAlbumChangeRequest) object can be accessed, it is an implementation class of MediaChangeRequest.

CreateOptions

Defines the options for creating an image or video asset.

The title must meet the following requirements:

  • It must not contain a file name extension.
  • The total length of the file name must be between 1 and 255 characters.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
titlestringNoYesTitle of the image or video.
Atomic service API: This API can be used in atomic services since API version 11.
subtype12+PhotoSubtypeNoYesSubtype of the image or video file.
Atomic service API: This API can be used in atomic services since API version 12.

FetchOptions

Defines the retrieval options.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
fetchColumnsArray<string>NoNoNames of the columns specified for query.
If this parameter is left blank for photos, photos are fetched by 'uri', 'media_type', 'subtype', and 'display_name' by default. An error will be thrown if get is used to obtain other attributes of this object.
Example: fetchColumns: ['uri', 'title'].
If this parameter is left blank for albums, albums are fetched by 'uri' and 'album_name' by default.
Atomic service API: This API can be used in atomic services since API version 20.
predicatesdataSharePredicates.DataSharePredicatesNoNoPredicates that specify the fetch criteria.
Atomic service API: This API can be used in atomic services since API version 20.

RequestOptions11+

Represents request options.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
deliveryModeDeliveryModeNoNoDelivery mode of the requested asset. The value can be FAST_MODE, HIGH_QUALITY_MODE, or BALANCE_MODE.
compatibleMode15+CompatibleModeNoYesHDR video transcoding policy, which can be FAST_ORIGINAL_FORMAT_MODE (maintaining the original HDR format) or COMPATIBLE_FORMAT_MODE (converting HDR content to SDR format). The default value is FAST_ORIGINAL_FORMAT_MODE.
mediaAssetProgressHandler15+MediaAssetProgressHandlerNoYesCallback used to return the HDR-to-SDR conversion progress.

ChangeData

Defines the return value of the listener callback.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
typeNotifyTypeNoNoNotification type.
urisArray<string>NoNoAll URIs with the same NotifyType, which can be PhotoAsset or Album.
extraUrisArray<string>NoNoURIs of the changed files in the album. The value may be undefined. Check whether the value is undefined before using it.

TextContextInfo12+

Represents the text information about the recommended images.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
textstringNoYesText based on which images are recommended. The text cannot exceed 250 characters. The default value is an empty string.

Example

import { BusinessError } from '@kit.BasicServicesKit';

async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
  try {
    let textInfo: photoAccessHelper.TextContextInfo = {
      text: 'Pandas at Shanghai Wild Zoo'
    }
    let recommendOptions: photoAccessHelper.RecommendationOptions = {
      textContextInfo: textInfo
    }
    let options: photoAccessHelper.PhotoSelectOptions = {
      MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE,
      maxSelectNumber: 1,
      recommendationOptions: recommendOptions
    }
    let photoPicker = new photoAccessHelper.PhotoViewPicker();
    photoPicker.select(options).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
    }).catch((err: BusinessError) => {
      console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
    });
  } catch (error) {
    let err: BusinessError = error as BusinessError;
    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
  }
}

PhotoCreationConfig12+

Represents the configuration for saving a media asset (image or video) to the media library, including the file name.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
titlestringNoYesTitle of the image or video. If this parameter is not passed, the system generates a title. The title must meet the following requirements:
- It must not contain a file name extension.
- The total length of the file name, which is in the format of title+file name extension, must be between 1 and 255 characters.
- It must not contain any invalid characters, which are:\ / : * ? " ' ` < > |{ } [ ]
fileNameExtensionstringNoNoFile name extension, for example, 'jpg'.
photoTypePhotoTypeNoNoType of the file to create, which can be IMAGE or VIDEO. See PhotoType.
subtypePhotoSubtypeNoYesImage or video file subtype. The default value is DEFAULT. See PhotoSubtype.

CreationSetting23+

Represents the configuration for saving images or videos to the media library, including the file name, file type, and other related parameters.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since API version 23.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
titlestringNoYesTitle of the image or video.
If this parameter is not passed, the system generates a value. The parameter specifications are as follows:
- It must not contain a file name extension.
- It must not contain any invalid characters, which are:\ / : * ? " ' ` < > |{ } [ ]
- The file name consists of the title and file name extension. The file name string length ranges from 1 to 255. Therefore, the title length cannot be too long.
fileNameExtensionstringNoNoFile name extension, for example, 'jpg'.
photoTypePhotoTypeNoNoPhotoType of the created media file, which can be IMAGE or VIDEO.

PhotoAssetChangeInfo20+

Describes the information about a media asset.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
uristringNoNoURI of the media asset.
mediaTypePhotoTypeNoNoType of the media asset (image or video).
albumUristringNoNoURI of the album that the media asset belongs to.

PhotoAssetChangeData20+

Describes the detailed change data of a media asset.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
assetBeforeChangePhotoAssetChangeInfo |nullNoNoData of the media asset before change. In the case of asset addition, assetBeforeChange is null.
assetAfterChangePhotoAssetChangeInfo |nullNoNoData of the media asset after change. In the case of asset deletion, assetAfterChange is null.
isContentChangedbooleanNoNoWhether the content of the media asset is changed. true if changed, false otherwise.
isDeletedbooleanNoNoWhether the media asset is deleted. true if deleted, false otherwise.

PhotoAssetChangeInfos20+

Describes the notification information about the change of a media asset.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
typeNotifyChangeTypeNoNoType of the media asset change.
assetChangeDatasPhotoAssetChangeData[] |nullNoNoArray of changed media assets. If all media assets need to be queried again, assetChangeDatas is null.
isForRecheckbooleanNoNoWhether the application should query all media assets again. true if the application should query all assets again, false otherwise.
NOTE
In scenarios involving bulk asset operations or abnormal notifications, isForRecheck will be true. In this case, the application should query all assets again.

AlbumChangeInfo20+

Describes the album information.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
albumTypeAlbumTypeNoNoType of the album.
albumSubtypeAlbumSubtypeNoNoSubtype of the album.
albumNamestringNoNoAlbum name.
albumUristringNoNoURI of the album.
imageCountnumberNoNoNumber of images in the album.
videoCountnumberNoNoNumber of videos in the album.
countnumberNoNoTotal number of assets in the album, including images and videos.
coverUristringNoNoURI of the album cover asset.

AlbumChangeData20+

Describes the detailed change data of an album.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
albumBeforeChangeAlbumChangeInfo |nullNoNoData of the album before change. If an album is added, albumBeforeChange is null.
albumAfterChangeAlbumChangeInfo |nullNoNoData of the album after change. In the case of album deletion, albumAfterChange is null.

AlbumChangeInfos20+

Describes the notification information about the change of an album.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
typeNotifyChangeTypeNoNoType of the album change.
albumChangeDatasAlbumChangeData[] |nullNoNoArray of changed albums. If all albums need to be queried again, albumChangeDatas is null.
isForRecheckbooleanNoNoWhether the application should query all albums again. true if the application should query all albums again, false otherwise.
NOTE
In scenarios involving bulk album operations or abnormal notifications, isForRecheck will be true. In this case, the application should query all albums again.

GridPinchMode23+

Represents the pinch mode of the grid in the picker.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since API version 23.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
gridPinchModeTypeGridPinchModeTypeNoYesGrid pinch mode. If this parameter is set, the pinch function is supported. Otherwise, the pinch function is not supported.
defaultGridLevelGridLevelNoYesGrid level after the picker is started. The default value is STANDARD.

AssetCompatibleCapability24+

Defines the asset compatibility capability.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since API version 24.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
supportedHighResolutionbooleanNoNoWhether high-resolution assets are supported. true: yes; false: no.

MediaLibraryAvailability

Defines the availability information of the media library.

Since: 26.0.0

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameTypeRead-OnlyOptionalDescription
availabilityStatusAvailabilityStatusNoNoAvailability status of the media library.
unavailabilityReasonstringNoNoReason why the media library is unavailable, for example, "Database corrupted".

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-mediaassetmanager-oh-mediaassetmanager

openharmony 鸿蒙 arkts-apis-photoAccessHelper-MediaAssetProgressHandler

openharmony 鸿蒙 arkts-apis-photoAccessHelper-AbsAlbum

openharmony 鸿蒙 arkts-apis-photoAccessHelper-PhotoAccessHelper

openharmony 鸿蒙 arkts-apis-photoAccessHelper-QuickImageDataHandler

openharmony 鸿蒙 capi-media-access-helper-capi-h

openharmony 鸿蒙 arkts-apis-photoAccessHelper-PhotoAsset

openharmony 鸿蒙 capi-mediaassetmanager-oh-movingphoto

openharmony 鸿蒙 capi-mediaassetmanager

openharmony 鸿蒙 capi-mediaassetmanager-medialibrary-requestid

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/1UuseUe8