• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Enums
2<!--Kit: Media Library Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @yixiaoff-->
5<!--SE: @liweilu1-->
6<!--TSE: @xchaosioda-->
7
8<!--Kit: Media Library Kit-->
9<!--Subsystem: Multimedia-->
10<!--Owner: @xuchangda;@yixiaoff-->
11<!--SE: @guxinggang;@liweilu1-->
12<!--TSE: @wangbeibei;@xchaosioda-->
13
14> **NOTE**
15>
16> 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.
17
18## PhotoType
19
20Enumerates the media file types.
21
22**Atomic service API**: This API can be used in atomic services since API version 11.
23
24**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
25
26| Name |  Value|  Description|
27| ----- |  ---- |  ---- |
28| IMAGE |  1 |  Image.|
29| VIDEO |  2 |  Video.|
30
31## PhotoSubtype<sup>12+</sup>
32
33Enumerates the [PhotoAsset](arkts-apis-photoAccessHelper-PhotoAsset.md) types.
34
35**Atomic service API**: This API can be used in atomic services since API version 12.
36
37**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
38
39| Name |  Value|  Description|
40| ----- |  ---- |  ---- |
41| DEFAULT |  0 |  Photo, which is the default type.|
42| MOVING_PHOTO |  3 |  Moving photo.|
43| BURST |  4 |  Burst photo.|
44
45## DynamicRangeType<sup>12+</sup>
46
47Enumerates the dynamic range types of media assets.
48
49**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
50
51| Name |  Value|  Description|
52| ----- |  ---- |  ---- |
53| SDR |  0 |  Standard dynamic range (SDR).|
54| HDR |  1 |  High dynamic range (HDR). |
55
56## AlbumType
57
58Enumerates the album types.
59
60**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
61
62| Name| Value   | Description     |
63| --------| ---- | ------------|
64| USER                | 0    | User album.  |
65| SYSTEM              | 1024 | System album.|
66
67## AlbumSubtype
68
69Enumerate the album subtypes.
70
71**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
72
73| Name    | Value         | Description  |
74| ----- | ---------- | --- |
75| USER\_GENERIC   | 1          | User album.|
76| FAVORITE        | 1025       | Favorites.|
77| VIDEO  | 1026       | Video album.|
78| IMAGE<sup>12+</sup>               | 1031       | Photo album.|
79| ANY    | 2147483647 | Any album.|
80
81## PositionType<sup>16+</sup>
82
83Enumerates the file locations.
84
85**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
86
87| Name |  Value|  Description|
88| ----- |  ---- |  ---- |
89| LOCAL |  1  |  Stored only on a local device.|
90| CLOUD |  2  |  Stored only on the cloud.|
91| LOCAL_AND_CLOUD |  3  |  Stored both on a local device and cloud.|
92
93## PhotoKeys
94
95Enumerates the keys available for image or video files.
96
97**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
98
99| Name         | Value             | Description                                                      |
100| ------------- | ------------------- | ---------------------------------------------------------- |
101| URI           | 'uri'                 | URI of the file.<br>**NOTE**: Only the [DataSharePredicates.equalTo](../apis-arkdata/js-apis-data-dataSharePredicates.md#equalto10) predicate can be used for this field during photo query.<br>**Atomic service API**: This API can be used in atomic services since API version 20.           |
102| PHOTO_TYPE    | 'media_type'           | Type of the file.<br>**Atomic service API**: This API can be used in atomic services since API version 20. |
103| DISPLAY_NAME  | 'display_name'        | File name displayed. The specifications are as follows:<br>- The file name consists of a valid file name and an image or video file name extension.<br>- The file name cannot exceed 255 characters.<br>- The file name cannot contain any of the following characters:<br>- The title does not contain any of the following characters:.. \ / : * ? " ' ` < > \| { } [ ]<br>**Atomic service API**: This API can be used in atomic services since API version 20.     |
104| SIZE          | 'size'                | File size, in bytes. The size of a moving photo includes the total size of the image and video.<br>**Atomic service API**: This API can be used in atomic services since API version 20.   |
105| DATE_ADDED    | 'date_added'          | Unix timestamp when the file was created, in seconds.<br>**Atomic service API**: This API can be used in atomic services since API version 20.        |
106| 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.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
107| DURATION      | 'duration'            | Duration, in ms.<br>**Atomic service API**: This API can be used in atomic services since API version 20.           |
108| WIDTH         | 'width'               | Image width, in pixels.<br>**Atomic service API**: This API can be used in atomic services since API version 20.                                   |
109| HEIGHT        | 'height'              | Image height, in pixels.<br>**Atomic service API**: This API can be used in atomic services since API version 20.              |
110| DATE_TAKEN    | 'date_taken'          | Unix timestamp when the photo was taken, in seconds.<br>**Atomic service API**: This API can be used in atomic services since API version 20.          |
111| ORIENTATION   | 'orientation'         | Orientation of the file, in degrees.<br>**Atomic service API**: This API can be used in atomic services since API version 20. |
112| FAVORITE      | 'is_favorite'            | Whether the file is marked as favorites.<br>**Atomic service API**: This API can be used in atomic services since API version 20.                |
113| TITLE         | 'title'               | Title of the file.<br>**Atomic service API**: This API can be used in atomic services since API version 20.                |
114| DATE_ADDED_MS<sup>12+</sup>  | 'date_added_ms'          | Unix timestamp when the file was created, in milliseconds.<br>**NOTE**: The photos queried cannot be sorted based on this field.<br>**Atomic service API**: This API can be used in atomic services since API version 20.     |
115| DATE_MODIFIED_MS<sup>12+</sup>  | '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.<br>**NOTE**: The photos queried cannot be sorted based on this field.<br>**Atomic service API**: This API can be used in atomic services since API version 20.          |
116| PHOTO_SUBTYPE<sup>12+</sup>   | 'subtype'               | Subtype of the media file.<br>**Atomic service API**: This API can be used in atomic services since API version 20.    |
117| DYNAMIC_RANGE_TYPE<sup>12+</sup>   | 'dynamic_range_type'               | Dynamic range type of the media asset.<br>**Atomic service API**: This API can be used in atomic services since API version 20.          |
118| COVER_POSITION<sup>12+</sup>   | 'cover_position'               | Position of the moving photo cover, which is the video timestamp (in μs) corresponding to the cover frame.<br>**Atomic service API**: This API can be used in atomic services since API version 20.       |
119| BURST_KEY<sup>12+</sup>   | 'burst_key'               | Unique ID of a group of burst photos.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
120| LCD_SIZE<sup>12+</sup>  | 'lcd_size'  | Width and height of an LCD image, in the format of a **width:height** string.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
121| THM_SIZE<sup>12+</sup>  | 'thm_size'  | Width and height of a thumbnail image, in the format of a **width:height** string.<br>**Atomic service API**: This API can be used in atomic services since API version 20.      |
122| DETAIL_TIME<sup>13+</sup>  | '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.<br>**Atomic service API**: This API can be used in atomic services since API version 20.      |
123| DATE_TAKEN_MS<sup>13+</sup>  | 'date_taken_ms'  | Unix timestamp when the image was captured, in milliseconds.<br>**Atomic service API**: This API can be used in atomic services since API version 20.  |
124| POSITION<sup>16+</sup>  | 'position'            | File location type.<br>**Atomic service API**: This API can be used in atomic services since API version 20.       |
125| MEDIA_SUFFIX<sup>18+</sup>  | 'media_suffix'            | File name extension.                              |
126
127## AlbumKeys
128
129Enumerates the album keys.
130
131**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
132
133| Name         | Value             | Description                                                      |
134| ------------- | ------------------- | ---------------------------------------------------------- |
135| URI           | 'uri'                 | URI of the album.                                                  |
136| ALBUM_NAME    | 'album_name'          | Name of the album.                                                  |
137
138## ResourceType<sup>11+</sup>
139
140Enumerates the types of the resources to write.
141
142**Atomic service API**: This API can be used in atomic services since API version 11.
143
144**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
145
146| Name |  Value|  Description|
147| ----- |  ---- |  ---- |
148| IMAGE_RESOURCE |  1 |  Image resource.|
149| VIDEO_RESOURCE |  2 |  Video resource.|
150
151## ImageFileType<sup>13+</sup>
152
153Enumerates the types of image files to save.
154
155**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
156
157| Name |  Value|  Description|
158| ----- |  ---- |  ---- |
159| JPEG  |  1 |  JPEG.|
160| HEIF  |  2 |  HEIF.|
161
162## NotifyType
163
164Enumerates the notification event types.
165
166**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
167
168| Name                     | Value  | Description                            |
169| ------------------------- | ---- | -------------------------------- |
170| NOTIFY_ADD                | 0    | A file asset or album is added.    |
171| NOTIFY_UPDATE             | 1    | A file asset or album is updated.    |
172| NOTIFY_REMOVE             | 2    | A file asset or album is removed.    |
173| NOTIFY_ALBUM_ADD_ASSET    | 3    | A file asset is added to the album.|
174| NOTIFY_ALBUM_REMOVE_ASSET | 4    | A file asset is removed from the album.|
175
176## DefaultChangeUri
177
178Enumerates the **DefaultChangeUri** subtypes.
179
180**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
181
182| Name             | Value                     | Description                                                        |
183| ----------------- | ----------------------- | ------------------------------------------------------------ |
184| 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.|
185| DEFAULT_ALBUM_URI | 'file://media/PhotoAlbum' | Default album URI, which must be used with **forChildUris{true}** to subscribe to change notifications of all albums.|
186
187## PhotoViewMIMETypes
188
189Enumerates the media file types.
190
191**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
192
193| Name                                   |  Value| Description      |
194|---------------------------------------|  ---- |----------|
195| IMAGE_TYPE                            |  'image/*' | Image.<br>**Atomic service API**: This API can be used in atomic services since API version 11.   |
196| VIDEO_TYPE                            |  'video/*' | Video.<br>**Atomic service API**: This API can be used in atomic services since API version 11.   |
197| IMAGE_VIDEO_TYPE                      |  '\*/*' | Image and video.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
198| MOVING_PHOTO_IMAGE_TYPE<sup>12+</sup> |  'image/movingPhoto' | Moving photo.<br>**Atomic service API**: This API can be used in atomic services since API version 12. |
199
200## RecommendationType<sup>11+</sup>
201
202Enumerates the types of recommended images.
203
204**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
205
206| Name |  Value|  Description|
207| ----- |  ---- | ---- |
208| QR_OR_BAR_CODE  |  1 | QR code or barcode.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
209| QR_CODE |  2 | QR code.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
210| BAR_CODE |  3 | Barcode.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
211| ID_CARD |  4 | ID card.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
212| PROFILE_PICTURE |  5 | Profile.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
213| PASSPORT<sup>12+</sup> |  6 | Passport.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
214| BANK_CARD<sup>12+</sup> |  7 | Bank card.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
215| DRIVER_LICENSE<sup>12+</sup> |  8 | Driver license.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
216| DRIVING_LICENSE<sup>12+</sup> |  9 | Vehicle license.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
217| FEATURED_SINGLE_PORTRAIT<sup>12+</sup> |  10 | Recommended portrait.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
218
219**Example**
220
221```ts
222import { BusinessError } from '@kit.BasicServicesKit';
223async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
224  try {
225    let recommendOptions: photoAccessHelper.RecommendationOptions = {
226      recommendationType: photoAccessHelper.RecommendationType.ID_CARD
227    }
228    let options: photoAccessHelper.PhotoSelectOptions = {
229      MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE,
230      maxSelectNumber: 1,
231      recommendationOptions: recommendOptions
232    }
233    let photoPicker = new photoAccessHelper.PhotoViewPicker();
234    photoPicker.select(options).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
235      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
236    }).catch((err: BusinessError) => {
237      console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
238    });
239  } catch (error) {
240    let err: BusinessError = error as BusinessError;
241    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
242  }
243}
244```
245
246## SingleSelectionMode<sup>18+</sup>
247
248Enumerates the single selection mode types.
249
250**Atomic service API**: This API can be used in atomic services since API version 18.
251
252**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
253
254| Name                                   |  Value| Description      |
255|---------------------------------------|  ---- |----------|
256| BROWSER_MODE                          |  0 | Mode for previewing large images.   |
257| SELECT_MODE                           |  1 | Mode for direct selection.   |
258| BROWSER_AND_SELECT_MODE               |  2 | Compatibility mode. Tapping the bottom-right area enables direct selection, whereas tapping elsewhere switches to large image preview mode.|
259
260## FilterOperator<sup>19+</sup>
261
262Enumerates the operators that can be used for filtering.
263
264**Atomic service API**: This API can be used in atomic services since API version 19.
265
266**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
267
268| Name |  Value|  Description|
269| ----- |  ---- |  ---- |
270| EQUAL_TO |  0 |  Equal to.|
271| NOT_EQUAL_TO |  1 |  Not equal to.|
272| MORE_THAN |  2 |  Greater than.|
273| LESS_THAN |  3 |  Less than.|
274| MORE_THAN_OR_EQUAL_TO |  4 |  Greater than or equal to.|
275| LESS_THAN_OR_EQUAL_TO |  5 |  Less than or equal to.|
276| BETWEEN |  6 |  Within the specified range.|
277
278## DeliveryMode<sup>11+</sup>
279
280Enumerates the asset delivery modes.
281
282**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
283
284| Name |  Value|  Description|
285| ----- |  ---- |  ---- |
286| FAST_MODE |  0 |  Fast mode.|
287| HIGH_QUALITY_MODE |  1 |  High-quality mode.|
288| BALANCE_MODE |  2 |  Balance mode.|
289
290## CompatibleMode<sup>15+</sup>
291
292Enumerates the compatible modes.
293
294**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
295
296| Name |  Value|  Description|
297| ----- | ---- | ---- |
298| ORIGINAL_FORMAT_MODE |  0 |  Maintains the original video format. |
299| COMPATIBLE_FORMAT_MODE    |  1 |  Converts the HDR content to SDR format.   |
300
301## CompleteButtonText<sup>14+</sup>
302
303Enumerates the text displayed on the complete button.
304
305**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
306
307| Name |  Value|  Description|
308| ----- | ---- | ---- |
309| TEXT_DONE<sup>14+</sup> |  0 |  The text "Done" is displayed.<br>**Atomic service API**: This API can be used in atomic services since API version 14.|
310| TEXT_SEND<sup>14+</sup>    |  1 |  The text "Send" is displayed.<br>**Atomic service API**: This API can be used in atomic services since API version 14.|
311| TEXT_ADD<sup>14+</sup> |  2 |  The text "Add" is displayed.<br>**Atomic service API**: This API can be used in atomic services since API version 14. |
312
313## NotifyChangeType<sup>20+</sup>
314
315Enumerates the types of changes that trigger the media asset or album change events.
316
317**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
318
319| Name                     | Value  | Description                            |
320| ------------------------- | ---- | -------------------------------- |
321| NOTIFY_CHANGE_ADD         | 0    | A media asset or an album is created.    |
322| NOTIFY_CHANGE_UPDATE      | 1    | A media asset or an album is modified.    |
323| NOTIFY_CHANGE_REMOVE      | 2    | A media asset or an album is deleted.    |
324
325## PhotoSource<sup>20+</sup>
326
327Enumerates the sources of the image or video data.
328
329**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
330
331| Name               | Value  | Description                                                                                                                |
332|-------------------|-----|--------------------------------------------------------------------------------------------------------------------|
333| ALL | 0   | Images and videos from all sources.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
334| CAMERA | 1   | Photo or video taken by the camera.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
335| SCREENSHOT | 2   | Screenshot or screen capture video.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
336