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
| Name | Value | Description |
|---|---|---|
| IMAGE | 1 | Image. |
| VIDEO | 2 | Video. |
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
| Name | Value | Description |
|---|---|---|
| DEFAULT | 0 | Photo, which is the default type. |
| MOVING_PHOTO | 3 | Moving photo. |
| BURST | 4 | Burst photo. |
DynamicRangeType12+
Enumerates the dynamic range types of media assets.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| SDR | 0 | Standard dynamic range (SDR). |
| HDR | 1 | High 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
| Name | Value | Description |
|---|---|---|
| USER | 0 | User album. |
| SYSTEM | 1024 | System album. |
| SOURCE23+ | 2048 | Album created by an application. |
AlbumSubtype
Enumerate the album subtypes.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| USER_GENERIC | 1 | User album. |
| FAVORITE | 1025 | Favorites. |
| VIDEO | 1026 | Video album. |
| IMAGE12+ | 1031 | Photo album. |
| SOURCE_GENERIC23+ | 2049 | Source album. |
| ANY | 2147483647 | Any album. |
PositionType16+
Enumerates the file locations.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| LOCAL | 1 | Stored only on a local device. |
| CLOUD | 2 | Stored only on the cloud. |
| LOCAL_AND_CLOUD | 3 | Stored both on a local device and cloud. |
PhotoKeys
Enumerates the keys available for image or video files.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| 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
| Name | Value | Description |
|---|---|---|
| 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
| Name | Value | Description |
|---|---|---|
| IMAGE_RESOURCE | 1 | Image resource. |
| VIDEO_RESOURCE | 2 | Video resource. |
ImageFileType13+
Enumerates the types of image files to save.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| JPEG | 1 | JPEG. |
| HEIF | 2 | HEIF. |
NotifyType
Enumerates the notification event types.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| NOTIFY_ADD | 0 | A file asset or album is added. |
| NOTIFY_UPDATE | 1 | A file asset or album is updated. |
| NOTIFY_REMOVE | 2 | A file asset or album is removed. |
| NOTIFY_ALBUM_ADD_ASSET | 3 | A file asset is added to the album. |
| NOTIFY_ALBUM_REMOVE_ASSET | 4 | A file asset is removed from the album. |
DefaultChangeUri
Enumerates the DefaultChangeUri subtypes.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| DEFAULT_PHOTO_URI | 'file://media/Photo' | Default PhotoAsset URI, which must be used with forSubUri{true} to subscribe to change notifications of all photo assets. |
| DEFAULT_ALBUM_URI | 'file://media/PhotoAlbum' | Default album URI, which must be used with forSubUri{true} to subscribe to change notifications of all albums. |
PhotoViewMIMETypes
Enumerates the media file types.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| 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
| Name | Value | Description |
|---|---|---|
| QR_OR_BAR_CODE | 1 | QR code or barcode. Atomic service API: This API can be used in atomic services since API version 11. |
| QR_CODE | 2 | QR code. Atomic service API: This API can be used in atomic services since API version 11. |
| BAR_CODE | 3 | Barcode. Atomic service API: This API can be used in atomic services since API version 11. |
| ID_CARD | 4 | ID card. Atomic service API: This API can be used in atomic services since API version 11. |
| PROFILE_PICTURE | 5 | Profile. Atomic service API: This API can be used in atomic services since API version 11. |
| PASSPORT12+ | 6 | Passport. Atomic service API: This API can be used in atomic services since API version 12. |
| BANK_CARD12+ | 7 | Bank card. Atomic service API: This API can be used in atomic services since API version 12. |
| DRIVER_LICENSE12+ | 8 | Driver license. Atomic service API: This API can be used in atomic services since API version 12. |
| DRIVING_LICENSE12+ | 9 | Vehicle license. Atomic service API: This API can be used in atomic services since API version 12. |
| FEATURED_SINGLE_PORTRAIT12+ | 10 | Recommended 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
| Name | Value | Description |
|---|---|---|
| BROWSER_MODE | 0 | Mode for previewing large images. |
| SELECT_MODE | 1 | Mode for direct selection. |
| BROWSER_AND_SELECT_MODE | 2 | Compatibility 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
| Name | Value | Description |
|---|---|---|
| EQUAL_TO | 0 | Equal to. |
| NOT_EQUAL_TO | 1 | Not equal to. |
| MORE_THAN | 2 | Greater than. |
| LESS_THAN | 3 | Less than. |
| MORE_THAN_OR_EQUAL_TO | 4 | Greater than or equal to. |
| LESS_THAN_OR_EQUAL_TO | 5 | Less than or equal to. |
| BETWEEN | 6 | Within 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
| Name | Value | Description |
|---|---|---|
| FAST_MODE | 0 | Fast 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_MODE | 1 | High-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_MODE | 2 | Balance 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
| Name | Value | Description |
|---|---|---|
| ORIGINAL_FORMAT_MODE | 0 | Maintains the original video format. |
| COMPATIBLE_FORMAT_MODE | 1 | Converts the HDR content to SDR format. |
CompleteButtonText14+
Enumerates the text displayed on the complete button.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| TEXT_DONE14+ | 0 | The text "Done" is displayed. Atomic service API: This API can be used in atomic services since API version 14. |
| TEXT_SEND14+ | 1 | The text "Send" is displayed. Atomic service API: This API can be used in atomic services since API version 14. |
| TEXT_ADD14+ | 2 | The 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
| Name | Value | Description |
|---|---|---|
| NOTIFY_CHANGE_ADD | 0 | A media asset or an album is created. |
| NOTIFY_CHANGE_UPDATE | 1 | A media asset or an album is modified. |
| NOTIFY_CHANGE_REMOVE | 2 | A media asset or an album is deleted. |
PhotoSource20+
Enumerates the sources of the image or video data.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| ALL | 0 | Images and videos from all sources. Atomic service API: This API can be used in atomic services since API version 20. |
| CAMERA | 1 | Image or video taken by the camera. Atomic service API: This API can be used in atomic services since API version 20. |
| SCREENSHOT | 2 | Screenshot 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
| Name | Value | Description |
|---|---|---|
| NOT_MOVING_PHOTO | 0 | The media file is not a moving photo. |
| MOVING_PHOTO_ENABLED | 1 | The moving photo effect is enabled. |
| MOVING_PHOTO_DISABLED | 2 | The 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
| Name | Value | Description |
|---|---|---|
| GRID_TO_PHOTO_BROWSER | 0 | Tap the grid icon to browse the large image. |
| PHOTO_BROWSER_SWIPE | 1 | Swipe 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
| Name | Value | Description |
|---|---|---|
| DEFAULT | 0 | The automatic playback of the moving photo is not supported. |
| AUTO_PLAY | 1 | The automatic playback of the moving photo is supported. |
VideoMode22+
Enumerates the log modes of video files.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| DEFAULT | 0 | Default 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_VIDEO | 1 | Video 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
| Name | Value | Description |
|---|---|---|
| EQUAL_TO | 1 | Checks 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_TO | 2 | Checks 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_THAN | 3 | Checks 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_THAN | 4 | Checks 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_TO | 5 | Checks 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_TO | 6 | Checks 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. |
| AND | 7 | Logical 'AND', similar to 'and' in database queries. No field or value is needed. |
| OR | 8 | Logical 'OR', similar to 'or' in database queries. No field or value is needed. |
| IN | 9 | Matches fields within a specified range, with a maximum value length of 10. |
| NOT_IN | 10 | Matches fields outside a specified range, with a maximum value length of 10. |
| BEGIN_WRAP | 11 | Adds 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_WRAP | 12 | Adds 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. |
| BETWEEN | 13 | Matches 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_BETWEEN | 14 | Matches 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
| Name | Value | Description |
|---|---|---|
| SPACIOUS | 0 | Spacious grid level. This level is the number of standard grid columns minus 1. |
| STANDARD | 1 | Standard 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. |
| COMPACT | 2 | Compact 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
| Name | Value | Description |
|---|---|---|
| FULL_FUNCTION_GRID | 0 | Users 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
| Name | Value | Description |
|---|---|---|
| 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
| Name | Value | Description |
|---|---|---|
| URI_FORMAT_ERROR | 0 | The URI format is incorrect or the URI is not a media library URI. |
| FILE_NOT_EXIST | 1 | The asset does not exist. The asset may be hidden, moved to the recycle bin, or permanently deleted. |
| READ_PERMISSION | 2 | The application has the read permission when obtaining the asset. |
| NO_READ_PERMISSION | 3 | The application does not have the read permission when obtaining the asset. |
PreferredCompatibleMode
Enumerates the transcoding modes based on the configured asset compatibility.
Since: 26.0.0
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 26.0.0.
System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core
| Name | Value | Description |
|---|---|---|
| DEFAULT | 0 | Transcoding is performed based on the configured asset compatibility function. |
| CURRENT | 1 | No transcoding is performed. Assets are returned in their original format. |
| COMPATIBLE | 2 | All assets are transcoded into the most widely compatible format (such as JPEG). |