openharmony 鸿蒙 arkts-apis-photoAccessHelper-e

2026-08-25 浏览 (1)

Enums

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';

PhotoType

Enumerates the media file types.

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

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
IMAGE1Image.
VIDEO2Video.

PhotoSubtype12+

Enumerates the PhotoAsset types.

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

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
DEFAULT0Photo, which is the default type.
MOVING_PHOTO3Moving photo.
BURST4Burst photo.

DynamicRangeType12+

Enumerates the dynamic range types of media assets.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
SDR0Standard dynamic range (SDR).
HDR1High dynamic range (HDR).

AlbumType

Enumerates the album types, for example, user albums, system albums, or albums created by an application.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
USER0User album.
SYSTEM1024System album.
SOURCE23+2048Album created by an application.

AlbumSubtype

Enumerate the album subtypes.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
USER_GENERIC1User album.
FAVORITE1025Favorites.
VIDEO1026Video album.
IMAGE12+1031Photo album.
SOURCE_GENERIC23+2049Source album.
ANY2147483647Any album.

PositionType16+

Enumerates the file locations.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
LOCAL1Stored only on a local device.
CLOUD2Stored only on the cloud.
LOCAL_AND_CLOUD3Stored both on a local device and cloud.

PhotoKeys

Enumerates the keys available for image or video files.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
URI'uri'URI of the file.
Note:
Only the DataSharePredicates.equalTo predicate can be used for this field during photo query.
Atomic service API: This API can be used in atomic services since API version 20.
PHOTO_TYPE'media_type'Type of the file.
Atomic service API: This API can be used in atomic services since API version 20.
DISPLAY_NAME'display_name'File name displayed. The file name must meet the following requirements:
- A valid file name must include a base name and a supported image or video extension.
- The file name length ranges from 1 to 255.
- The base name must not contain any invalid characters, which are:.. \ / : * ? " ' ` < > |{ } [ ].
Atomic service API: This API can be used in atomic services since API version 20.
SIZE'size'File size, in bytes. The size of a moving photo includes the total size of the image and video.
Atomic service API: This API can be used in atomic services since API version 20.
DATE_ADDED'date_added'Unix timestamp when the file was created, in seconds.
Atomic service API: This API can be used in atomic services since API version 20.
DATE_MODIFIED'date_modified'Unix timestamp when the file content (not the file name) was last modified, in seconds. This value is updated when the file content is modified, but not when the file name is modified.
Atomic service API: This API can be used in atomic services since API version 20.
DURATION'duration'Duration, in ms.
Atomic service API: This API can be used in atomic services since API version 20.
WIDTH'width'Image width, in pixels.
Atomic service API: This API can be used in atomic services since API version 20.
HEIGHT'height'Image height, in pixels.
Atomic service API: This API can be used in atomic services since API version 20.
DATE_TAKEN'date_taken'Unix timestamp when the photo was taken, in seconds.
Atomic service API: This API can be used in atomic services since API version 20.
ORIENTATION'orientation'Orientation of the file, in degrees.
Atomic service API: This API can be used in atomic services since API version 20.
FAVORITE'is_favorite'Whether the file is marked as favorites.
Atomic service API: This API can be used in atomic services since API version 20.
TITLE'title'Title of the file.
Atomic service API: This API can be used in atomic services since API version 20.
DATE_ADDED_MS12+'date_added_ms'Unix timestamp when the file was created, in milliseconds.
Note:
The photos queried cannot be sorted based on this field.
Atomic service API: This API can be used in atomic services since API version 20.
DATE_MODIFIED_MS12+'date_modified_ms'Unix timestamp when the file was modified, in milliseconds. This value is updated when the file content is modified, but not when the file name is modified.
Note:
The photos queried cannot be sorted based on this field.
Atomic service API: This API can be used in atomic services since API version 20.
PHOTO_SUBTYPE12+'subtype'Subtype of the media file.
Atomic service API: This API can be used in atomic services since API version 20.
DYNAMIC_RANGE_TYPE12+'dynamic_range_type'Dynamic range type of the media asset.
Atomic service API: This API can be used in atomic services since API version 20.
COVER_POSITION12+'cover_position'Position of the moving photo cover, which is the video timestamp (in μs) corresponding to the cover frame.
Atomic service API: This API can be used in atomic services since API version 20.
BURST_KEY12+'burst_key'Unique ID of a group of burst photos.
Atomic service API: This API can be used in atomic services since API version 20.
LCD_SIZE12+'lcd_size'Width and height of an LCD image, in the format of a width:height string.
Atomic service API: This API can be used in atomic services since API version 20.
THM_SIZE12+'thm_size'Width and height of a thumbnail image, in the format of a width:height string.
Atomic service API: This API can be used in atomic services since API version 20.
DETAIL_TIME13+'detail_time'Detailed time. The value is a string of time when the image or video was taken in the time zone and does not change with the time zone.
Atomic service API: This API can be used in atomic services since API version 20.
DATE_TAKEN_MS13+'date_taken_ms'Unix timestamp when the image was captured, in milliseconds.
Atomic service API: This API can be used in atomic services since API version 20.
POSITION16+'position'File location type.
Atomic service API: This API can be used in atomic services since API version 20.
MEDIA_SUFFIX18+'media_suffix'File name extension.
OWNER_ALBUM_ID22+'owner_album_id'ID of the album to which the photo belongs.
ASPECT_RATIO22+'aspect_ratio'Aspect ratio of the image or video.
Model restriction: This API can be used only in the stage model.
CHANGE_TIME23+'change_time'Time when the photo is changed.
LOCAL_ASSET_SIZE'local_asset_size'Actual size of the local file.
- This property indicates only the size of the local file. The default value 0 indicates a cloud file or an unidentified local file.
- This property changes when the local file is a dynamic photo and the mode changes. For example, when a dynamic photo in Gallery is in the disabled state, this property indicates only the size of the cover frame.
Since: 26.0.0
Model restriction: This API can be used only in the stage model.

AlbumKeys

Enumerates the album keys.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
URI'uri'URI of the album.
ALBUM_NAME'album_name'Name of the album.
ALBUM_LPATH23+'lpath'Virtual path of the album.
Albums and their virtual path values:
- Camera application album: '/DCIM/Camera'
- Screenshot application album: '/Pictures/Screenshots'
- Screen recording application album: '/Pictures/Screenrecords'
- User-created album: '/Pictures/Users/{Custom album name}'
CHANGE_TIME23+'change_time'Time when the album is changed.

ResourceType11+

Enumerates the types of the resources to write.

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

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
IMAGE_RESOURCE1Image resource.
VIDEO_RESOURCE2Video resource.

ImageFileType13+

Enumerates the types of image files to save.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
JPEG1JPEG.
HEIF2HEIF.

NotifyType

Enumerates the notification event types.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
NOTIFY_ADD0A file asset or album is added.
NOTIFY_UPDATE1A file asset or album is updated.
NOTIFY_REMOVE2A file asset or album is removed.
NOTIFY_ALBUM_ADD_ASSET3A file asset is added to the album.
NOTIFY_ALBUM_REMOVE_ASSET4A file asset is removed from the album.

DefaultChangeUri

Enumerates the DefaultChangeUri subtypes.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
DEFAULT_PHOTO_URI'file://media/Photo'Default PhotoAsset URI, which must be used with forChildUris{true} to subscribe to change notifications of all photo assets.
DEFAULT_ALBUM_URI'file://media/PhotoAlbum'Default album URI, which must be used with forChildUris{true} to subscribe to change notifications of all albums.

PhotoViewMIMETypes

Enumerates the media file types.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
IMAGE_TYPE'image/*'Image.
Atomic service API: This API can be used in atomic services since API version 11.
VIDEO_TYPE'video/*'Video.
Atomic service API: This API can be used in atomic services since API version 11.
IMAGE_VIDEO_TYPE'*/*'Image and video.
Atomic service API: This API can be used in atomic services since API version 11.
MOVING_PHOTO_IMAGE_TYPE12+'image/movingPhoto'Moving photo.
Atomic service API: This API can be used in atomic services since API version 12.

RecommendationType11+

Enumerates the types of recommended images.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
QR_OR_BAR_CODE1QR code or barcode.
Atomic service API: This API can be used in atomic services since API version 11.
QR_CODE2QR code.
Atomic service API: This API can be used in atomic services since API version 11.
BAR_CODE3Barcode.
Atomic service API: This API can be used in atomic services since API version 11.
ID_CARD4ID card.
Atomic service API: This API can be used in atomic services since API version 11.
PROFILE_PICTURE5Profile.
Atomic service API: This API can be used in atomic services since API version 11.
PASSPORT12+6Passport.
Atomic service API: This API can be used in atomic services since API version 12.
BANK_CARD12+7Bank card.
Atomic service API: This API can be used in atomic services since API version 12.
DRIVER_LICENSE12+8Driver license.
Atomic service API: This API can be used in atomic services since API version 12.
DRIVING_LICENSE12+9Vehicle license.
Atomic service API: This API can be used in atomic services since API version 12.
FEATURED_SINGLE_PORTRAIT12+10Recommended portrait.
Atomic service API: This API can be used in atomic services since API version 12.

Example

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

async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
  try {
    let recommendOptions: photoAccessHelper.RecommendationOptions = {
      recommendationType: photoAccessHelper.RecommendationType.ID_CARD
    }
    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}`);
  }
}

SingleSelectionMode18+

Enumerates the single selection mode types.

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

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
BROWSER_MODE0Mode for previewing large images.
SELECT_MODE1Mode for direct selection.
BROWSER_AND_SELECT_MODE2Compatibility mode. Tapping the bottom-right area enables direct selection, whereas tapping elsewhere switches to large image preview mode.

FilterOperator19+

Enumerates the operators that can be used for filtering.

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

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
EQUAL_TO0Equal to.
NOT_EQUAL_TO1Not equal to.
MORE_THAN2Greater than.
LESS_THAN3Less than.
MORE_THAN_OR_EQUAL_TO4Greater than or equal to.
LESS_THAN_OR_EQUAL_TO5Less than or equal to.
BETWEEN6Within the specified range.

DeliveryMode11+

Enumerates the asset delivery modes.

These modes are used for segmented photo or video delivery. If the device does not support segmentation, the three delivery modes below work the same way and just return the requested image or video directly. The request result is returned through the onDataPrepared callback.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
FAST_MODE0Fast mode.
For segmented photo or video delivery, if a high-quality version is available, it quickly returns the callback for that high-quality version. If only a low-quality version is available, it returns the callback for the low-quality version right away.
HIGH_QUALITY_MODE1High-quality mode.
For segmented photo or video delivery, if a high-quality version is available, it quickly returns the callback for that high-quality version. If only a low-quality version is available, it starts a task to generate a high-quality version and returns the callback for the high-quality version once that version is ready.
BALANCE_MODE2Balance mode.
- For segmented photo delivery, if a high-quality version is available, it quickly returns the callback for that high-quality version. If only a low-quality version is available, it returns the callback for the low-quality version, starts a task to generate a high-quality version, and returns the callback for the high-quality version once that version is ready.
- For segmented video delivery, if a high-quality version is available, it quickly returns the callback for that high-quality version. If only a low-quality version is available, it returns the callback for the low-quality version right away.

CompatibleMode15+

Enumerates the compatible modes.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
ORIGINAL_FORMAT_MODE0Maintains the original video format.
COMPATIBLE_FORMAT_MODE1Converts the HDR content to SDR format.

CompleteButtonText14+

Enumerates the text displayed on the complete button.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
TEXT_DONE14+0The text "Done" is displayed.
Atomic service API: This API can be used in atomic services since API version 14.
TEXT_SEND14+1The text "Send" is displayed.
Atomic service API: This API can be used in atomic services since API version 14.
TEXT_ADD14+2The text "Add" is displayed.
Atomic service API: This API can be used in atomic services since API version 14.

NotifyChangeType20+

Enumerates the types of changes that trigger the media asset or album change events.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
NOTIFY_CHANGE_ADD0A media asset or an album is created.
NOTIFY_CHANGE_UPDATE1A media asset or an album is modified.
NOTIFY_CHANGE_REMOVE2A media asset or an album is deleted.

PhotoSource20+

Enumerates the sources of the image or video data.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
ALL0Images and videos from all sources.
Atomic service API: This API can be used in atomic services since API version 20.
CAMERA1Image or video taken by the camera.
Atomic service API: This API can be used in atomic services since API version 20.
SCREENSHOT2Screenshot or screen capture video.
Atomic service API: This API can be used in atomic services since API version 20.

MovingPhotoBadgeStateType22+

Enumerates the states of moving photo badges.

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

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
NOT_MOVING_PHOTO0The media file is not a moving photo.
MOVING_PHOTO_ENABLED1The moving photo effect is enabled.
MOVING_PHOTO_DISABLED2The moving photo effect is disabled.

SceneType23+

Enumerates the scene types of the moving photo playback.

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

NameValueDescription
GRID_TO_PHOTO_BROWSER0Tap the grid icon to browse the large image.
PHOTO_BROWSER_SWIPE1Swipe left or right in the large image scene.

PlayMode23+

Enumerates whether to support automatic playback of the moving photo.

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

NameValueDescription
DEFAULT0The automatic playback of the moving photo is not supported.
AUTO_PLAY1The automatic playback of the moving photo is supported.

VideoMode22+

Enumerates the log modes of video files.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
DEFAULT0Default type.
A value of 0 indicates that the video is either not in log mode or its type has not yet been determined. This value may later be updated to 1 for some videos after type determination, so it is not recommended for use in queries.
LOG_VIDEO1Video file in log mode.

OperationType22+

Enumerates the predicates.

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 22.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
EQUAL_TO1Checks for equality, using the first element of the value array to match the predicate. If the array is longer, only the first element is considered.
NOT_EQUAL_TO2Checks for inequality, using the first element of the value array to match the predicate. If the array is longer, only the first element is considered.
GREATER_THAN3Checks whether the value is greater than the predicate, using the first element of the value array to match the predicate. If the array is longer, only the first element is considered.
LESS_THAN4Checks whether the value is less than the predicate, using the first element of the value array to match the predicate. If the array is longer, only the first element is considered.
GREATER_THAN_OR_EQUAL_TO5Checks whether the value is greater than or equal to the predicate, using the first element of the value array to match the predicate. If the array is longer, only the first element is considered.
LESS_THAN_OR_EQUAL_TO6Checks whether the value is less than or equal to the predicate, using the first element of the value array to match the predicate. If the array is longer, only the first element is considered.
AND7Logical 'AND', similar to 'and' in database queries. No field or value is needed.
OR8Logical 'OR', similar to 'or' in database queries. No field or value is needed.
IN9Matches fields within a specified range, with a maximum value length of 10.
NOT_IN10Matches fields outside a specified range, with a maximum value length of 10.
BEGIN_WRAP11Adds a left parenthesis to the predicate, similar to "(" in database queries. It must be used with a right parenthesis. No field or value is needed.
END_WRAP12Adds a right parenthesis to the predicate, similar to ")" in database queries. It must be used with a left parenthesis. No field or value is needed.
BETWEEN13Matches fields within a specified range,
including both endpoints (closed interval). It uses the first two elements of the value array, where the first element is the lower boundary and the second is the upper boundary. For example, in the array [1, 2, 3, 4], the first two elements are used, with 1 as the lower boundary and 2 as the upper boundary.
NOT_BETWEEN14Matches fields outside a specified range,
excluding both endpoints (open interval). It uses the first two elements of the value array, where the first element is the lower boundary and the second is the upper boundary. For example, in the array [1, 2, 3, 4], the first two elements are used, with 1 as the lower boundary and 2 as the upper boundary.

GridLevel23+

Enumerates the levels of grid columns after Picker is started.

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

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

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
SPACIOUS0Spacious grid level. This level is the number of standard grid columns minus 1.
STANDARD1Standard grid level. The number of standard grid columns varies with the device size. If no number of standard grid columns is configured, the system uses the default number of columns.
COMPACT2Compact grid level. This level is the number of standard grid columns plus 1.

GridPinchModeType23+

Enumerates the grid pinch mode types.

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

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

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
FULL_FUNCTION_GRID0Users are allowed to pinch the grid, and then select it or click it to operate the large image.

AvailabilityStatus

Enumerates the availability status 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

NameValueDescription
AVAILABLE'available'The media library is available.
UNAVAILABLE'unavailable'The media library is unavailable.

MediaAssetPermissionState

Enumerates the permission states for reading media library assets.

Since: 26.0.0

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

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

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

NameValueDescription
URI_FORMAT_ERROR0The URI format is incorrect or the URI is not a media library URI.
FILE_NOT_EXIST1The asset does not exist. The asset may be hidden, moved to the recycle bin, or permanently deleted.
READ_PERMISSION2The application has the read permission when obtaining the asset.
NO_READ_PERMISSION3The application does not have the read permission when obtaining the asset.

你可能感兴趣的鸿蒙文章

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/gKmyhVFM