• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Interfaces (Others)
2<!--Kit: Media Library Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @yixiaoff-->
5<!--SE: @liweilu1-->
6<!--TSE: @xchaosioda-->
7
8> **NOTE**
9>
10> 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.
11
12## MediaChangeRequest<sup>11+</sup>
13
14Media change request, which is the parent class of the asset change request and album change request.
15
16> **NOTE**
17>
18> **MediaChangeRequest** takes effect only after [applyChanges](arkts-apis-photoAccessHelper-PhotoAccessHelper.md#applychanges11) is called.
19
20**Atomic service API**: This API can be used in atomic services since API version 11.
21
22**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
23
24## CreateOptions
25
26Options for creating an image or video asset.
27
28The title must meet the following requirements:
29
30- It does not contain a file name extension.
31- The file name cannot exceed 255 characters.
32- It does not contain any of the following characters:<br> . .. \ / : * ? " ' ` < > | { } [ ]
33
34**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
35
36| Name                  | Type               | Mandatory| Description                                             |
37| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
38| title                  | string                          | No | Title of the image or video.<br>**Atomic service API**: This API can be used in atomic services since API version 11. |
39| subtype<sup>12+</sup>  | [PhotoSubtype](arkts-apis-photoAccessHelper-e.md#photosubtype12) | No | Subtype of the image or video file.<br>**Atomic service API**: This API can be used in atomic services since API version 12. |
40
41## FetchOptions
42
43Defines the retrieval options.
44
45**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
46
47| Name                  | Type               | Readable| Writable| Description                                             |
48| ---------------------- | ------------------- | ---- |---- | ------------------------------------------------ |
49| fetchColumns           | Array&lt;string&gt; | Yes  | Yes  | Names of the columns specified for query.<br>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](arkts-apis-photoAccessHelper-PhotoAsset.md#get) is used to obtain other attributes of this object. <br>Example: **fetchColumns: ['uri', 'title']**.<br>If this parameter is left blank for albums, albums are fetched by **'uri'** and **'album_name'** by default.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
50| predicates           | [dataSharePredicates.DataSharePredicates](../apis-arkdata/js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Yes  | Predicates that specify the fetch criteria.<br>**Atomic service API**: This API can be used in atomic services since API version 20.|
51
52## RequestOptions<sup>11+</sup>
53
54Represents request options.
55
56**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
57
58| Name                  | Type                       | Read-Only| Optional| Description                                        |
59| ---------------------- |----------------------------| ---- | ---- | ------------------------------------------- |
60| deliveryMode           | [DeliveryMode](arkts-apis-photoAccessHelper-e.md#deliverymode11) | No  | No  | Delivery mode of the requested asset. The value can be **FAST_MODE**, **HIGH_QUALITY_MODE**, or **BALANCE_MODE**.|
61| compatibleMode<sup>15+</sup>      | [CompatibleMode](arkts-apis-photoAccessHelper-e.md#compatiblemode15) | No  | Yes  | HDR 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**.|
62| mediaAssetProgressHandler<sup>15+</sup> | [MediaAssetProgressHandler](arkts-apis-photoAccessHelper-MediaAssetProgressHandler.md) | No  | Yes  | Callback used to return the HDR-to-SDR conversion progress.|
63
64## ChangeData
65
66Defines the return value of the listener callback.
67
68**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
69
70| Name   | Type                       | Readable| Writable| Description                                                        |
71| ------- | --------------------------- | ---- | ---- | ------------------------------------------------------------ |
72| type    | [NotifyType](arkts-apis-photoAccessHelper-e.md#notifytype) | Yes  | No  | Notification type.                                      |
73| uris    | Array&lt;string&gt;         | Yes  | No  | All URIs with the same [NotifyType](arkts-apis-photoAccessHelper-e.md#notifytype), which can be **PhotoAsset** or **Album**.|
74| extraUris | Array&lt;string&gt;         | Yes  | No  | URIs of the changed files in the album. The value may be undefined. Check whether the value is undefined before using it.                          |
75
76## TextContextInfo<sup>12+</sup>
77
78Represents the text information about the recommended images.
79
80**Atomic service API**: This API can be used in atomic services since API version 12.
81
82**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
83
84| Name                   | Type               | Mandatory| Description                         |
85| ----------------------- | ------------------- | ---- | -------------------------------- |
86| text | string   | No  | Text based on which images are recommended. The text cannot exceed 250 characters. The default value is an empty string.|
87
88**Example**
89
90```ts
91import { BusinessError } from '@kit.BasicServicesKit';
92async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper) {
93  try {
94    let textInfo: photoAccessHelper.TextContextInfo = {
95      text: 'Pandas at Shanghai Wild Zoo'
96    }
97    let recommendOptions: photoAccessHelper.RecommendationOptions = {
98      textContextInfo: textInfo
99    }
100    let options: photoAccessHelper.PhotoSelectOptions = {
101      MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE,
102      maxSelectNumber: 1,
103      recommendationOptions: recommendOptions
104    }
105    let photoPicker = new photoAccessHelper.PhotoViewPicker();
106    photoPicker.select(options).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
107      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
108    }).catch((err: BusinessError) => {
109      console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
110    });
111  } catch (error) {
112    let err: BusinessError = error as BusinessError;
113    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
114  }
115}
116```
117
118## PhotoCreationConfig<sup>12+</sup>
119
120Represents the configuration for saving a media asset (image or video) to the media library, including the file name.
121
122**Atomic service API**: This API can be used in atomic services since API version 12.
123
124**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
125
126| Name                  | Type               | Mandatory| Description                                             |
127| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
128| title | string | No | Title of the image or video. If this parameter is not passed, the system generates a title. The title must meet the following requirements:<br>- It does not contain a file name extension.<br>- The file name, which is in the format of title+file name extension, does not exceed 255 characters.<br>- The title does not contain any of the following characters:\ / : * ? " ' ` < > \| { } [ ]|
129| fileNameExtension | string | Yes | File name extension, for example, **'jpg'**.|
130| photoType | [PhotoType](arkts-apis-photoAccessHelper-e.md#phototype) | Yes | Type of the file to create, which can be **IMAGE** or **VIDEO**. See [PhotoType](arkts-apis-photoAccessHelper-e.md#phototype).|
131| subtype | [PhotoSubtype](arkts-apis-photoAccessHelper-e.md#photosubtype12) | No | Image or video file subtype. Currently, only **DEFAULT** is supported. See [PhotoSubtype](arkts-apis-photoAccessHelper-e.md#photosubtype12).|
132
133## PhotoAssetChangeInfo<sup>20+</sup>
134
135Describes the information about a media asset.
136
137**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
138
139| Name|   Type  | Read-Only|  Optional| Description     |
140| ---- | ------- | ---- |  ---- | ----- |
141| uri       | string  | No| No| URI of the media asset.|
142| mediaType | [PhotoType](arkts-apis-photoAccessHelper-e.md#phototype) | No| No | Type of the media asset (image or video).|
143| albumUri  | string  | No| No| URI of the album that the media asset belongs to. |
144
145## PhotoAssetChangeData<sup>20+</sup>
146
147Describes the detailed change data of a media asset.
148
149**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
150
151| Name    | Type               | Read-Only| Optional| Description |
152| ---- | ------- | ---- |  ---- | ----- |
153| assetBeforeChange | [PhotoAssetChangeInfo](#photoassetchangeinfo20) \| null | No| No| Data of the media asset before change. In the case of asset addition, **assetBeforeChange** is null.|
154| assetAfterChange  | [PhotoAssetChangeInfo](#photoassetchangeinfo20) \| null | No| No | Data of the media asset after change. In the case of asset deletion, **assetAfterChange** is null.|
155| isContentChanged  |boolean  | No| No| Whether the content of the media asset is changed. **true** if changed, **false** otherwise. |
156| isDeleted         |boolean  | No| No| Whether the media asset is deleted. **true** if deleted, **false** otherwise. |
157
158## PhotoAssetChangeInfos<sup>20+</sup>
159
160Describes the notification information about the change of a media asset.
161
162**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
163
164| Name                  | Type               | Read-Only| Optional| Description   |
165| ---- | ------- | ---- |  ---- | ----- |
166| type       | [NotifyChangeType](arkts-apis-photoAccessHelper-e.md#notifychangetype20)  | No| No| Type of the media asset change.|
167| assetChangeDatas | [PhotoAssetChangeData](#photoassetchangedata20)[] \| null | No|  No| Array of changed media assets. If all media assets need to be queried again, **assetChangeDatas** is null. |
168| isForRecheck    | boolean  | No| No| Whether the application should query all media assets again. **true** if the application should query all assets again, **false** otherwise.<br>**NOTE**: In special cases or abnormal notification scenarios, **isForRecheck** will be **true**. In this case, the application should query all assets again. |
169
170## AlbumChangeInfo<sup>20+</sup>
171
172Describes the album information.
173
174**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
175
176| Name | Type               | Read-Only| Optional| Description                                             |
177| ---- | ------- | ---- |  ---- | ----- |
178| albumType | [AlbumType](arkts-apis-photoAccessHelper-e.md#albumtype)  | No| No| Type of the album.|
179| albumSubtype  | [AlbumSubtype](arkts-apis-photoAccessHelper-e.md#albumsubtype) | No| No | Subtype of the album.|
180| albumName  | string  |No|No| Album name. |
181| albumUri  | string  |No|No| URI of the album. |
182| imageCount  | number  |No|No| Number of images in the album. |
183| videoCount  | number  |No|No| Number of videos in the album. |
184| count       | number  |No|No| Total number of assets in the album, including images and videos. |
185| coverUri  | string  |No|No| URI of the album cover asset. |
186
187## AlbumChangeData<sup>20+</sup>
188
189Describes the detailed change data of an album.
190
191**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
192
193| Name                  | Type               | Read-Only| Optional| Description               |
194| ---- | ------- | ---- |  ---- | ----- |
195| albumBeforeChange | [AlbumChangeInfo](#albumchangeinfo20) \| null | No| No| Data of the album before change. If an album is added, **albumBeforeChange** is null.|
196| albumAfterChange  | [AlbumChangeInfo](#albumchangeinfo20) \| null | No| No | Data of the album after change. In the case of album deletion, **albumAfterChange** is null.|
197
198## AlbumChangeInfos<sup>20+</sup>
199
200Describes the notification information about the change of an album.
201
202**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
203
204| Name                  | Type               | Read-Only| Optional| Description          |
205| ---- | ------- | ---- |  ---- | ----- |
206| type       | [NotifyChangeType](arkts-apis-photoAccessHelper-e.md#notifychangetype20)  | No| No| Type of the album change.|
207| albumChangeDatas   | [AlbumChangeData](#albumchangedata20)[] \| null | No| No| Array of changed albums. If all albums need to be queried again, **albumChangeDatas** is null. |
208| isForRecheck          | boolean  | No| No| Whether the application should query all albums again. **true** if the application should query all albums again, **false** otherwise.<br>**NOTE**: In special cases or abnormal notification scenarios, **isForRecheck** will be **true**. In this case, the application should query all albums again. |
209