1# MediaAssetManager
2
3
4## Overview
5
6Provides APIs for managing media assets.
7
8For details about the development guide and sample, see [Requesting Media Assets Using MediaAssetManager (C/C++)](../../media/medialibrary/using-ndk-mediaassetmanager-for-request-resource.md).
9
10**Since**: 12
11
12
13## Summary
14
15
16### Files
17
18| Name| Description|
19| -------- | -------- |
20| [media_access_helper_capi.h](media__access__helper__capi_8h.md) | Defines the APIs for album management. |
21| [media_asset_base_capi.h](media__asset__base__capi_8h.md) | Defines the structs and enums of the media asset manager. |
22| [media_asset_capi.h](media__asset__capi_8h.md) | Defines the APIs related to media assets. |
23| [media_asset_change_request_capi.h](media__asset__change__request__capi_8h.md) | Defines the APIs related to media asset change requests. |
24| [media_asset_manager_capi.h](media__asset__manager__capi_8h.md) | Defines the APIs of the media asset manager. |
25| [moving_photo_capi.h](moving__photo__capi_8h.md) | Defines the APIs related to moving photos. |
26
27
28### Structs
29
30| Name| Description|
31| -------- | -------- |
32| struct  [MediaLibrary_RequestId](_media_library___request_id.md) | Defines a request ID. |
33| struct  [MediaLibrary_RequestOptions](_media_library___request_options.md) | Defines the options related to the media asset quality and delivery mode to set. |
34
35
36### Types
37
38| Name| Description|
39| -------- | -------- |
40| typedef struct [OH_MediaAssetManager](#oh_mediaassetmanager) [OH_MediaAssetManager](#oh_mediaassetmanager) | Defines a struct for the media asset manager. |
41| typedef struct [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) | Defines a struct for a media asset change request. |
42| typedef struct [OH_MovingPhoto](#oh_movingphoto) [OH_MovingPhoto](#oh_movingphoto) | Defines a struct for a moving photo. |
43| typedef struct [OH_MediaAsset](#oh_mediaasset) [OH_MediaAsset](#oh_mediaasset) | Defines a struct for a media asset. |
44| typedef struct [MediaLibrary_RequestId](_media_library___request_id.md) [MediaLibrary_RequestId](#medialibrary_requestid) | Defines a struct for a request ID. |
45| typedef enum [MediaLibrary_ErrorCode](#medialibrary_errorcode-1) [MediaLibrary_ErrorCode](#medialibrary_errorcode) | Defines an enum for error codes. |
46| typedef enum [MediaLibrary_DeliveryMode](#medialibrary_deliverymode-1) [MediaLibrary_DeliveryMode](#medialibrary_deliverymode) | Defines an enum for delivery modes of the requested media asset. |
47| typedef struct [MediaLibrary_RequestOptions](_media_library___request_options.md) [MediaLibrary_RequestOptions](#medialibrary_requestoptions) | Defines an enum for options related to the media asset quality and delivery mode to set. |
48| typedef enum [MediaLibrary_MediaType](#medialibrary_mediatype-1) [MediaLibrary_MediaType](#medialibrary_mediatype) | Defines an enum for media asset types. |
49| typedef enum [MediaLibrary_MediaSubType](#medialibrary_mediasubtype-1) [MediaLibrary_MediaSubType](#medialibrary_mediasubtype) | Defines an enum for media asset subtypes. |
50| typedef enum [MediaLibrary_ResourceType](#medialibrary_resourcetype-1) [MediaLibrary_ResourceType](#medialibrary_resourcetype) | Defines an enum for media library resource types. |
51| typedef enum [MediaLibrary_ImageFileType](#medialibrary_imagefiletype-1) [MediaLibrary_ImageFileType](#medialibrary_imagefiletype) | Defines an enum for image file types. |
52| typedef enum [MediaLibrary_MediaQuality](#medialibrary_mediaquality-1) [MediaLibrary_MediaQuality](#medialibrary_mediaquality) | Defines an enum for media resource quality. |
53| typedef enum [MediaLibrary_MediaContentType](#medialibrary_mediacontenttype-1) [MediaLibrary_MediaContentType](#medialibrary_mediacontenttype) | Defines an enum for media content types. |
54| typedef void(\* [OH_MediaLibrary_OnDataPrepared](#oh_medialibrary_ondataprepared)) (int32_t result, [MediaLibrary_RequestId](_media_library___request_id.md) requestId) | Defines a function pointer to the callback to be invoked when the requested media asset is ready. |
55| typedef void(\* [OH_MediaLibrary_OnImageDataPrepared](#oh_medialibrary_onimagedataprepared)) ([MediaLibrary_ErrorCode](#medialibrary_errorcode) result, [MediaLibrary_RequestId](_media_library___request_id.md) requestId, [MediaLibrary_MediaQuality](#medialibrary_mediaquality) mediaQuality, [MediaLibrary_MediaContentType](#medialibrary_mediacontenttype) type, OH_ImageSourceNative \*imageSourceNative) | Defines a function pointer to the callback to be invoked when the requested image is ready. |
56| typedef void(\* [OH_MediaLibrary_OnMovingPhotoDataPrepared](#oh_medialibrary_onmovingphotodataprepared)) ([MediaLibrary_ErrorCode](#medialibrary_errorcode) result, [MediaLibrary_RequestId](_media_library___request_id.md) requestId, [MediaLibrary_MediaQuality](#medialibrary_mediaquality) mediaQuality, [MediaLibrary_MediaContentType](#medialibrary_mediacontenttype) type, [OH_MovingPhoto](#oh_movingphoto) \*movingPhoto) | Defines a function pointer to the callback to be invoked when the requested moving photo is ready. |
57
58
59### Enums
60
61| Name| Description|
62| -------- | -------- |
63| [MediaLibrary_ErrorCode](#medialibrary_errorcode-1) {<br>MEDIA_LIBRARY_OK = 0,<br>MEDIA_LIBRARY_PERMISSION_DENIED = 201,<br>MEDIA_LIBRARY_PARAMETER_ERROR = 401,<br>MEDIA_LIBRARY_NO_SUCH_FILE = 23800101,<br>MEDIA_LIBRARY_INVALID_DISPLAY_NAME = 23800102,<br>MEDIA_LIBRARY_INVALID_ASSET_URI = 23800103,<br>MEDIA_LIBRARY_INVALID_PHOTO_KEY = 23800104,<br>MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED = 23800201,<br>MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR = 23800301<br>} | Enumerates the error codes.|
64| [MediaLibrary_DeliveryMode](#medialibrary_deliverymode-1) {<br>MEDIA_LIBRARY_FAST_MODE = 0,<br>MEDIA_LIBRARY_HIGH_QUALITY_MODE = 1,<br>MEDIA_LIBRARY_BALANCED_MODE = 2 } | Enumerates the delivery modes of the requested media asset.|
65| [MediaLibrary_MediaType](#medialibrary_mediatype-1) {<br>MEDIA_LIBRARY_IMAGE = 1,<br>MEDIA_LIBRARY_VIDEO = 2 } | Enumerates the media asset types.|
66| [MediaLibrary_MediaSubType](#medialibrary_mediasubtype-1) {<br>MEDIA_LIBRARY_DEFAULT = 0,<br>MEDIA_LIBRARY_MOVING_PHOTO = 3,<br>MEDIA_LIBRARY_BURST = 4 } | Enumerates the media asset subtypes.|
67| [MediaLibrary_ResourceType](#medialibrary_resourcetype-1) {<br>MEDIA_LIBRARY_IMAGE_RESOURCE = 1,<br>MEDIA_LIBRARY_VIDEO_RESOURCE = 2 } | Enumerates the media library resource types.|
68| [MediaLibrary_ImageFileType](#medialibrary_imagefiletype-1) {<br>MEDIA_LIBRARY_IMAGE_JPEG = 1 } | Enumerates the image file types.|
69| [MediaLibrary_MediaQuality](#medialibrary_mediaquality-1) {<br>MEDIA_LIBRARY_QUALITY_FAST = 1,<br>MEDIA_LIBRARY_QUALITY_FULL = 2 } | Enumerates the media resource quality.|
70| [MediaLibrary_MediaContentType](#medialibrary_mediacontenttype-1) {<br>MEDIA_LIBRARY_COMPRESSED = 1,<br>MEDIA_LIBRARY_PICTURE_OBJECT = 2 } | Enumerates the media content types.|
71
72
73### Functions
74
75| Name| Description|
76| -------- | -------- |
77| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAccessHelper_ApplyChanges](#oh_mediaaccesshelper_applychanges) ([OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) \*changeRequest) | Applies changes to an asset or album. |
78| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetUri](#oh_mediaasset_geturi) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, const char \*\*uri) | Obtains the URI of a media asset. |
79| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetMediaType](#oh_mediaasset_getmediatype) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, [MediaLibrary_MediaType](#medialibrary_mediatype) \*mediaType) | Obtains the type of a media asset. |
80| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetMediaSubType](#oh_mediaasset_getmediasubtype) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, [MediaLibrary_MediaSubType](#medialibrary_mediasubtype) \*mediaSubType) | Obtains the subtype of a media asset. |
81| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetDisplayName](#oh_mediaasset_getdisplayname) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, const char \*\*displayName) | Obtains the displayed name of a media asset. |
82| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetSize](#oh_mediaasset_getsize) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*size) | Obtains the size of a media asset file. |
83| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetDateAdded](#oh_mediaasset_getdateadded) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*dateAdded) | Obtains the date when a media asset was added. |
84| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetDateModified](#oh_mediaasset_getdatemodified) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*dateModified) | Obtains the date when a media asset was last modified. |
85| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetDateTaken](#oh_mediaasset_getdatetaken) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*dateTaken) | Obtains the date when a media asset was taken. |
86| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetDateAddedMs](#oh_mediaasset_getdateaddedms) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*dateAddedMs) | Obtains the date when a media asset was added, in ms. |
87| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetDateModifiedMs](#oh_mediaasset_getdatemodifiedms) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*dateModifiedMs) | Obtains the time when a media asset was last modified, in ms. |
88| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetDuration](#oh_mediaasset_getduration) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*duration) | Obtains the duration of a media asset, in ms. |
89| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetWidth](#oh_mediaasset_getwidth) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*width) | Obtains the image width (in pixels) of a media asset. |
90| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetHeight](#oh_mediaasset_getheight) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*height) | Obtains the image height (in pixels) of a media asset. |
91| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetOrientation](#oh_mediaasset_getorientation) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*orientation) | Obtains the orientation of a media asset, in degrees. |
92| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_IsFavorite](#oh_mediaasset_isfavorite) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, uint32_t \*favorite) | Checks whether a media asset is favorited. |
93| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_GetTitle](#oh_mediaasset_gettitle) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset, const char \*\*title) | Obtains the title of a media asset. |
94| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAsset_Release](#oh_mediaasset_release) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset) | Releases a media asset. |
95| [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) \* [OH_MediaAssetChangeRequest_Create](#oh_mediaassetchangerequest_create) ([OH_MediaAsset](#oh_mediaasset) \*mediaAsset) | Creates an [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance. |
96| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAssetChangeRequest_AddResourceWithUri](#oh_mediaassetchangerequest_addresourcewithuri) ([OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) \*changeRequest, [MediaLibrary_ResourceType](#medialibrary_resourcetype) resourceType, char \*fileUri) | Adds a resource of the given URI. |
97| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAssetChangeRequest_AddResourceWithBuffer](#oh_mediaassetchangerequest_addresourcewithbuffer) ([OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) \*changeRequest, [MediaLibrary_ResourceType](#medialibrary_resourcetype) resourceType, uint8_t \*buffer, uint32_t length) | Adds a resource using **ArrayBuffer** data. |
98| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAssetChangeRequest_GetWriteCacheHandler](#oh_mediaassetchangerequest_getwritecachehandler) ([OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) \*changeRequest, int32_t \*fd) | Obtains the handler used for writing a file to cache. |
99| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAssetChangeRequest_SaveCameraPhoto](#oh_mediaassetchangerequest_savecameraphoto) ([OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) \*changeRequest, [MediaLibrary_ImageFileType](#medialibrary_imagefiletype) imageFileType) | Saves the photo taken by the camera. |
100| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAssetChangeRequest_DiscardCameraPhoto](#oh_mediaassetchangerequest_discardcameraphoto) ([OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) \*changeRequest) | Discards the photo taken by the camera. |
101| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAssetChangeRequest_Release](#oh_mediaassetchangerequest_release) ([OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) \*changeRequest) | Releases an [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance. |
102| [OH_MediaAssetManager](#oh_mediaassetmanager) \* [OH_MediaAssetManager_Create](#oh_mediaassetmanager_create) (void) | Creates a **MediaAssetManager** instance. |
103| [MediaLibrary_RequestId](_media_library___request_id.md) [OH_MediaAssetManager_RequestImageForPath](#oh_mediaassetmanager_requestimageforpath) ([OH_MediaAssetManager](#oh_mediaassetmanager) \*manager, const char \*uri, [MediaLibrary_RequestOptions](_media_library___request_options.md) requestOptions, const char \*destPath, [OH_MediaLibrary_OnDataPrepared](#oh_medialibrary_ondataprepared) callback) | Requests an image in the specified directory. |
104| [MediaLibrary_RequestId](_media_library___request_id.md) [OH_MediaAssetManager_RequestVideoForPath](#oh_mediaassetmanager_requestvideoforpath) ([OH_MediaAssetManager](#oh_mediaassetmanager) \*manager, const char \*uri, [MediaLibrary_RequestOptions](_media_library___request_options.md) requestOptions, const char \*destPath, [OH_MediaLibrary_OnDataPrepared](#oh_medialibrary_ondataprepared) callback) | Requests a video in the specified directory. |
105| bool [OH_MediaAssetManager_CancelRequest](#oh_mediaassetmanager_cancelrequest) ([OH_MediaAssetManager](#oh_mediaassetmanager) \*manager, const [MediaLibrary_RequestId](_media_library___request_id.md) requestId) | Cancels a request based on the request ID. |
106| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAssetManager_RequestMovingPhoto](#oh_mediaassetmanager_requestmovingphoto) ([OH_MediaAssetManager](#oh_mediaassetmanager) \*manager, [OH_MediaAsset](#oh_mediaasset) \*mediaAsset, [MediaLibrary_RequestOptions](_media_library___request_options.md) requestOptions, [MediaLibrary_RequestId](_media_library___request_id.md) \*requestId, [OH_MediaLibrary_OnMovingPhotoDataPrepared](#oh_medialibrary_onmovingphotodataprepared) callback) | Requests moving photo resources based on different policies. |
107| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAssetManager_RequestImage](#oh_mediaassetmanager_requestimage) ([OH_MediaAssetManager](#oh_mediaassetmanager) \*manager, [OH_MediaAsset](#oh_mediaasset) \*mediaAsset, [MediaLibrary_RequestOptions](_media_library___request_options.md) requestOptions, [MediaLibrary_RequestId](_media_library___request_id.md) \*requestId, [OH_MediaLibrary_OnImageDataPrepared](#oh_medialibrary_onimagedataprepared) callback) | Requests an image. |
108| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MediaAssetManager_Release](#oh_mediaassetmanager_release) ([OH_MediaAssetManager](#oh_mediaassetmanager) \*manager) | Releases an [OH_MediaAssetManager](#oh_mediaassetmanager) instance. |
109| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MovingPhoto_GetUri](#oh_movingphoto_geturi) ([OH_MovingPhoto](#oh_movingphoto) \*movingPhoto, const char \*\*uri) | Obtains the URI of a moving photo. |
110| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MovingPhoto_RequestContentWithUris](#oh_movingphoto_requestcontentwithuris) ([OH_MovingPhoto](#oh_movingphoto) \*movingPhoto, char \*imageUri, char \*videoUri) | Requests the image data and video data of a moving photo and writes them to the specified URIs, respectively. |
111| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MovingPhoto_RequestContentWithUri](#oh_movingphoto_requestcontentwithuri) ([OH_MovingPhoto](#oh_movingphoto) \*movingPhoto, [MediaLibrary_ResourceType](#medialibrary_resourcetype) resourceType, char \*uri) | Requests the moving photo content of the specified resource type and writes it to the specified URI. |
112| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MovingPhoto_RequestContentWithBuffer](#oh_movingphoto_requestcontentwithbuffer) ([OH_MovingPhoto](#oh_movingphoto) \*movingPhoto, [MediaLibrary_ResourceType](#medialibrary_resourcetype) resourceType, const uint8_t \*\*buffer, uint32_t \*size) | Requests the moving photo content of the specified resource type and returns it in ArrayBuffer format. |
113| [MediaLibrary_ErrorCode](#medialibrary_errorcode) [OH_MovingPhoto_Release](#oh_movingphoto_release) ([OH_MovingPhoto](#oh_movingphoto) \*movingPhoto) | Releases an [OH_MovingPhoto](#oh_movingphoto) instance. |
114
115
116## Type Description
117
118
119### MediaLibrary_DeliveryMode
120
121```
122typedef enum MediaLibrary_DeliveryMode MediaLibrary_DeliveryMode
123```
124**Description**<br>
125Defines an enum for delivery modes of the requested media asset.
126
127The delivery modes include the following:
128
129- **MEDIA_LIBRARY_FAST_MODE**: deliver the media asset available without considering its quality.
130
131- **MEDIA_LIBRARY_HIGH_QUALITY_MODE**: deliver a media asset with high quality. If there is no high-quality asset available, trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
132
133- **MEDIA_LIBRARY_BALANCED_MODE**: return the high-quality asset if there is any. Otherwise, return a low-quality asset first and trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
134
135**Since**: 12
136
137
138### MediaLibrary_ErrorCode
139
140```
141typedef enum MediaLibrary_ErrorCode MediaLibrary_ErrorCode
142```
143**Description**<br>
144Defines an enum for error codes.
145
146**Since**: 12
147
148
149### MediaLibrary_ImageFileType
150
151```
152typedef enum MediaLibrary_ImageFileType MediaLibrary_ImageFileType
153```
154**Description**<br>
155Defines an enum for image file types.
156
157**Since**: 12
158
159
160### MediaLibrary_MediaContentType
161
162```
163typedef enum MediaLibrary_MediaContentType MediaLibrary_MediaContentType
164```
165**Description**<br>
166Defines an enum for media content types.
167
168**Since**: 12
169
170
171### MediaLibrary_MediaQuality
172
173```
174typedef enum MediaLibrary_MediaQuality MediaLibrary_MediaQuality
175```
176**Description**<br>
177Defines an enum for media resource quality, which varies with the specified delivery mode for the requested media asset.
178
179- **MEDIA_LIBRARY_FAST_MODE**: deliver the media asset available without considering its quality.
180
181- **MEDIA_LIBRARY_HIGH_QUALITY_MODE**: deliver a media asset with high quality. If there is no high-quality asset available, trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
182
183- **MEDIA_LIBRARY_BALANCED_MODE**: return the high-quality asset if there is any. Otherwise, return a low-quality asset first and trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
184
185**Since**: 12
186
187
188### MediaLibrary_MediaSubType
189
190```
191typedef enum MediaLibrary_MediaSubType MediaLibrary_MediaSubType
192```
193**Description**<br>
194Defines an enum for media asset subtypes.
195
196**Since**: 12
197
198
199### MediaLibrary_MediaType
200
201```
202typedef enum MediaLibrary_MediaType MediaLibrary_MediaType
203```
204**Description**<br>
205Defines an enum for media asset types.
206
207**Since**: 12
208
209
210### MediaLibrary_RequestId
211
212```
213typedef struct MediaLibrary_RequestId MediaLibrary_RequestId
214```
215**Description**<br>
216Defines a request ID.
217
218A value of this type is returned when a media asset is requested. The request ID can be used to cancel a request. If a request fails, an all-zero value, for example, **00000000-0000-0000-0000-000000000000** is returned.
219
220**Since**: 12
221
222
223### MediaLibrary_RequestOptions
224
225```
226typedef struct MediaLibrary_RequestOptions MediaLibrary_RequestOptions
227```
228**Description**<br>
229Defines how media assets are requested and processed.
230
231You can use this struct to set options related to the media asset quality, delivery mode, and more.
232
233**Since**: 12
234
235
236### MediaLibrary_ResourceType
237
238```
239typedef enum MediaLibrary_ResourceType MediaLibrary_ResourceType
240```
241**Description**<br>
242Define an enum for media library resource types.
243
244**Since**: 12
245
246
247### OH_MediaAsset
248
249```
250typedef struct OH_MediaAsset OH_MediaAsset
251```
252**Description**<br>
253Defines a struct for a media asset.
254
255This struct provides the capability of encapsulating media file attributes.
256
257**Since**: 12
258
259
260### OH_MediaAssetChangeRequest
261
262```
263typedef struct OH_MediaAssetChangeRequest OH_MediaAssetChangeRequest
264```
265**Description**<br>
266Defines a struct for a media asset change request.
267
268This struct provides the capability of handling media asset change requests.
269
270**Since**: 12
271
272
273### OH_MediaAssetManager
274
275```
276typedef struct OH_MediaAssetManager OH_MediaAssetManager
277```
278**Description**<br>
279Defines a struct for the media asset manager.
280
281You can use this struct to create a media asset manager instance. If the creation fails, a null pointer is returned.
282
283**Since**: 12
284
285
286### OH_MediaLibrary_OnDataPrepared
287
288```
289typedef void (*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId)
290```
291**Description**<br>
292Defines a function pointer to the callback to be invoked when the requested media asset is ready.
293
294**Since**: 12
295
296**Parameters**
297
298| Name| Description|
299| -------- | -------- |
300| result | Processing result of the requested asset. |
301| requestId | Request ID. |
302
303
304### OH_MediaLibrary_OnImageDataPrepared
305
306```
307typedef void (*OH_MediaLibrary_OnImageDataPrepared)(MediaLibrary_ErrorCode result, MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type, OH_ImageSourceNative* imageSourceNative)
308```
309**Description**<br>
310Defines a function pointer to the callback to be invoked when the requested image is ready.
311
312This callback is called when the requested image source is ready.
313
314**Since**: 12
315
316**Parameters**
317
318| Name| Description|
319| -------- | -------- |
320| result | [MediaLibrary_ErrorCode](#medialibrary_errorcode-1).|
321| requestId | [MediaLibrary_RequestId](_media_library___request_id.md).|
322| mediaQuality | [MediaLibrary_MediaQuality](#medialibrary_mediaquality-1).|
323| type | [MediaLibrary_MediaContentType](#medialibrary_mediacontenttype-1).|
324| imageSourceNative | [OH_ImageSourceNative](../apis-image-kit/_image___native_module.md#oh_imagesourcenative) obtained when the requested image source is ready.|
325
326
327### OH_MediaLibrary_OnMovingPhotoDataPrepared
328
329```
330typedef void (*OH_MediaLibrary_OnMovingPhotoDataPrepared)(MediaLibrary_ErrorCode result, MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type, OH_MovingPhoto* movingPhoto)
331```
332**Description**<br>
333Defines a function pointer to the callback to be invoked when the requested moving photo is ready.
334
335This callback is invoked when the requested moving photo is ready.
336
337**Since**: 13
338
339**Parameters**
340
341| Name| Description|
342| -------- | -------- |
343| result | [MediaLibrary_ErrorCode](#medialibrary_errorcode-1). |
344| requestId | [MediaLibrary_RequestId](_media_library___request_id.md). |
345| mediaQuality | [MediaLibrary_MediaQuality](#medialibrary_mediaquality-1). |
346| type | [MediaLibrary_MediaContentType](#medialibrary_mediacontenttype-1). |
347| movingPhoto | Pointer to the [OH_MovingPhoto](#oh_movingphoto) obtained. |
348
349
350### OH_MovingPhoto
351
352```
353typedef struct OH_MovingPhoto OH_MovingPhoto
354```
355**Description**<br>
356Defines a struct for a moving photo.
357
358This struct provides the capability of obtaining information about a moving photo.
359
360**Since**: 13
361
362
363## Enum Description
364
365
366### MediaLibrary_DeliveryMode
367
368```
369enum MediaLibrary_DeliveryMode
370```
371**Description**<br>
372Enumerates the delivery modes of the requested media asset.
373
374The delivery modes include the following:
375
376- **MEDIA_LIBRARY_FAST_MODE**: deliver the media asset available without considering its quality.
377
378- **MEDIA_LIBRARY_HIGH_QUALITY_MODE**: deliver a media asset with high quality. If there is no high-quality asset available, trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
379
380- **MEDIA_LIBRARY_BALANCED_MODE**: return the high-quality asset if there is any. Otherwise, return a low-quality asset first and trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
381
382**Since**: 12
383
384| Value| Description|
385| -------- | -------- |
386| MEDIA_LIBRARY_FAST_MODE  | Fast mode.  |
387| MEDIA_LIBRARY_HIGH_QUALITY_MODE  | High-quality mode.  |
388| MEDIA_LIBRARY_BALANCED_MODE  | Balance mode.  |
389
390
391### MediaLibrary_ErrorCode
392
393```
394enum MediaLibrary_ErrorCode
395```
396**Description**<br>
397Enumerates the error codes.
398
399**Since**: 12
400
401| Value| Description|
402| -------- | -------- |
403| MEDIA_LIBRARY_OK | The operation is successful.|
404| MEDIA_LIBRARY_PERMISSION_DENIED | The access is denied due to lack of permission.|
405| MEDIA_LIBRARY_PARAMETER_ERROR | Mandatory parameter is not specified, the parameter type is incorrect, or parameter verification failed.|
406| MEDIA_LIBRARY_NO_SUCH_FILE | The file does not exist.|
407| MEDIA_LIBRARY_INVALID_DISPLAY_NAME | Invalid display name.|
408| MEDIA_LIBRARY_INVALID_ASSET_URI | Invalid asset URI.|
409| MEDIA_LIBRARY_INVALID_PHOTO_KEY | Invalid PhotoKey.|
410| MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED | The operation is not supported.|
411| MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR | Internal system error. Possible causes:<br>1. The database is corrupted.<br>2. The file system is abnormal.<br>3. The IPC request timed out.|
412
413
414### MediaLibrary_ImageFileType
415
416```
417enum MediaLibrary_ImageFileType
418```
419**Description**<br>
420Enumerates the image file types.
421
422**Since**: 12
423
424| Value| Description|
425| -------- | -------- |
426| MEDIA_LIBRARY_IMAGE_JPEG  | JPEG.  |
427
428
429### MediaLibrary_MediaContentType
430
431```
432enum MediaLibrary_MediaContentType
433```
434**Description**<br>
435Enumerates the media content types.
436
437**Since**: 12
438
439| Value| Description|
440| -------- | -------- |
441| MEDIA_LIBRARY_COMPRESSED  | Compressed media content.  |
442| MEDIA_LIBRARY_PICTURE_OBJECT  | Image object.  |
443
444
445### MediaLibrary_MediaQuality
446
447```
448enum MediaLibrary_MediaQuality
449```
450**Description**<br>
451Enumerates the media resource quality, which varies with the specified delivery mode for the requested media asset.
452
453- **MEDIA_LIBRARY_FAST_MODE**: deliver the media asset available without considering its quality.
454
455- **MEDIA_LIBRARY_HIGH_QUALITY_MODE**: deliver a media asset with high quality. If there is no high-quality asset available, trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
456
457- **MEDIA_LIBRARY_BALANCED_MODE**: return the high-quality asset if there is any. Otherwise, return a low-quality asset first and trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
458
459**Since**: 12
460
461| Value| Description|
462| -------- | -------- |
463| MEDIA_LIBRARY_QUALITY_FAST  | Media asset available without considering its quality.  |
464| MEDIA_LIBRARY_QUALITY_FULL  | High-quality media asset.  |
465
466
467### MediaLibrary_MediaSubType
468
469```
470enum MediaLibrary_MediaSubType
471```
472**Description**<br>
473Enumerates the media asset subtypes.
474
475**Since**: 12
476
477| Value| Description|
478| -------- | -------- |
479| MEDIA_LIBRARY_DEFAULT  | Photo (default type).  |
480| MEDIA_LIBRARY_MOVING_PHOTO  | Moving photo.  |
481| MEDIA_LIBRARY_BURST  | Burst photo.  |
482
483
484### MediaLibrary_MediaType
485
486```
487enum MediaLibrary_MediaType
488```
489**Description**<br>
490Enumerates the media asset types.
491
492**Since**: 12
493
494| Value| Description|
495| -------- | -------- |
496| MEDIA_LIBRARY_IMAGE  | Image.  |
497| MEDIA_LIBRARY_VIDEO  | Video.  |
498
499
500### MediaLibrary_ResourceType
501
502```
503enum MediaLibrary_ResourceType
504```
505**Description**<br>
506Enumerates the media library resource types.
507
508**Since**: 12
509
510| Value| Description|
511| -------- | -------- |
512| MEDIA_LIBRARY_IMAGE_RESOURCE  | Image resource.  |
513| MEDIA_LIBRARY_VIDEO_RESOURCE  | Video resource.  |
514
515
516## Function Description
517
518
519### OH_MediaAccessHelper_ApplyChanges()
520
521```
522MediaLibrary_ErrorCode OH_MediaAccessHelper_ApplyChanges(OH_MediaAssetChangeRequest* changeRequest)
523```
524**Description**<br>
525Applies changes to an asset or album.
526
527**Since**: 12
528
529**Parameters**
530
531| Name| Description|
532| -------- | -------- |
533| changeRequest | Pointer to the [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance. |
534
535**Required permissions**
536
537ohos.permission.WRITE_IMAGEVIDEO
538
539**Returns**
540
541[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
542
543- **MEDIA_LIBRARY_OK**: The operation is successful.
544
545- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
546  Possible causes:
547  1. There is mandatory parameter that is not specified.
548  2. The parameter type is incorrect.
549  3. The parameter verification failed.
550
551- **MEDIA_LIBRARY_PERMISSION_DENIED**: The access is denied due to lack of permission.
552
553- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
554
555
556### OH_MediaAsset_GetDateAdded()
557
558```
559ediaLibrary_ErrorCode OH_MediaAsset_GetDateAdded(OH_MediaAsset* mediaAsset, uint32_t* dateAdded)
560```
561**Description**<br>
562Obtains the date when a media asset was added.
563
564**Since**: 13
565
566**Parameters**
567
568| Name| Description|
569| -------- | -------- |
570| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
571| dateAdded | Pointer to the date obtained. The value is the number of seconds elapsed since the Unix Epoch time (00:00:00 UTC on January 1, 1970). |
572
573**Returns**
574
575[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
576
577- **MEDIA_LIBRARY_OK**: The operation is successful.
578
579- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
580  Possible causes:
581  1. There is mandatory parameter that is not specified.
582  2. The parameter type is incorrect.
583  3. The parameter verification failed.
584
585- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
586
587
588### OH_MediaAsset_GetDateAddedMs()
589
590```
591MediaLibrary_ErrorCode OH_MediaAsset_GetDateAddedMs(OH_MediaAsset* mediaAsset, uint32_t* dateAddedMs)
592```
593**Description**<br>
594Obtains the date when a media asset was added, in ms.
595
596**Since**: 13
597
598**Parameters**
599
600| Name| Description|
601| -------- | -------- |
602| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
603| dateAddedMs | Pointer to the time obtained, in ms. The value is the number of milliseconds elapsed since the Unix Epoch time. |
604
605**Returns**
606
607[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
608
609- **MEDIA_LIBRARY_OK**: The operation is successful.
610
611- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
612  Possible causes:
613  1. There is mandatory parameter that is not specified.
614  2. The parameter type is incorrect.
615  3. The parameter verification failed.
616
617- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
618
619
620### OH_MediaAsset_GetDateModified()
621
622```
623MediaLibrary_ErrorCode OH_MediaAsset_GetDateModified(OH_MediaAsset* mediaAsset, uint32_t* dateModified)
624```
625**Description**<br>
626Obtains the date when a media asset (content not the media asset name) was last modified.
627
628**Since**: 13
629
630**Parameters**
631
632| Name| Description|
633| -------- | -------- |
634| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
635| dateModified | Pointer to the date obtained. The value is the number of milliseconds elapsed since the Unix Epoch time. |
636
637**Returns**
638
639[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
640
641- **MEDIA_LIBRARY_OK**: The operation is successful.
642
643- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
644  Possible causes:
645  1. There is mandatory parameter that is not specified.
646  2. The parameter type is incorrect.
647  3. The parameter verification failed.
648
649- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
650
651
652### OH_MediaAsset_GetDateModifiedMs()
653
654```
655MediaLibrary_ErrorCode OH_MediaAsset_GetDateModifiedMs(OH_MediaAsset* mediaAsset, uint32_t* dateModifiedMs)
656```
657**Description**<br>
658Obtains the date when a media asset (content not the media asset name) was last modified, in ms.
659
660**Since**: 12
661
662**Parameters**
663
664| Name| Description|
665| -------- | -------- |
666| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
667| dateModifiedMs | Pointer to the date obtained, in ms. The value is the number of milliseconds elapsed since the Unix Epoch time. |
668
669**Returns**
670
671[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
672
673- **MEDIA_LIBRARY_OK**: The operation is successful.
674
675- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
676  Possible causes:
677  1. There is mandatory parameter that is not specified.
678  2. The parameter type is incorrect.
679  3. The parameter verification failed.
680
681- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
682
683
684### OH_MediaAsset_GetDateTaken()
685
686```
687MediaLibrary_ErrorCode OH_MediaAsset_GetDateTaken(OH_MediaAsset* mediaAsset, uint32_t* dateTaken)
688```
689**Description**<br>
690Obtains the date when a media asset was taken.
691
692**Since**: 13
693
694**Parameters**
695
696| Name| Description|
697| -------- | -------- |
698| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
699| dateTaken | Pointer to the media asset taken date obtained. The value is the number of seconds elapsed since the Unix Epoch time. |
700
701**Returns**
702
703[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
704
705- **MEDIA_LIBRARY_OK**: The operation is successful.
706
707- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
708  Possible causes:
709  1. There is mandatory parameter that is not specified.
710  2. The parameter type is incorrect.
711  3. The parameter verification failed.
712
713- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
714
715
716### OH_MediaAsset_GetDisplayName()
717
718```
719MediaLibrary_ErrorCode OH_MediaAsset_GetDisplayName(OH_MediaAsset* mediaAsset, const char** displayName)
720```
721**Description**<br>
722Obtains the displayed name of a media asset.
723
724**Since**: 12
725
726**Parameters**
727
728| Name| Description|
729| -------- | -------- |
730| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
731| displayName | Pointer to the displayed name obtained. |
732
733**Returns**
734
735[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
736
737- **MEDIA_LIBRARY_OK**: The operation is successful.
738
739- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
740  Possible causes:
741  1. There is mandatory parameter that is not specified.
742  2. The parameter type is incorrect.
743  3. The parameter verification failed.
744
745- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
746
747
748### OH_MediaAsset_GetDuration()
749
750```
751MediaLibrary_ErrorCode OH_MediaAsset_GetDuration(OH_MediaAsset* mediaAsset, uint32_t* duration)
752```
753**Description**<br>
754Obtains the duration of a media asset, in ms.
755
756**Since**: 13
757
758**Parameters**
759
760| Name| Description|
761| -------- | -------- |
762| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
763| duration | Pointer to the duration obtained, in ms. |
764
765**Returns**
766
767[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
768
769- **MEDIA_LIBRARY_OK**: The operation is successful.
770
771- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
772  Possible causes:
773  1. There is mandatory parameter that is not specified.
774  2. The parameter type is incorrect.
775  3. The parameter verification failed.
776
777- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
778
779
780### OH_MediaAsset_GetHeight()
781
782```
783MediaLibrary_ErrorCode OH_MediaAsset_GetHeight(OH_MediaAsset* mediaAsset, uint32_t* height)
784```
785**Description**<br>
786Obtains the image height (in pixels) of a media asset.
787
788**Since**: 12
789
790**Parameters**
791
792| Name| Description|
793| -------- | -------- |
794| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
795| height | Pointer to the image height of the media resource, in pixels. |
796
797**Returns**
798
799[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
800
801- **MEDIA_LIBRARY_OK**: The operation is successful.
802
803- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
804  Possible causes:
805  1. There is mandatory parameter that is not specified.
806  2. The parameter type is incorrect.
807  3. The parameter verification failed.
808
809- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
810
811### OH_MediaAsset_GetMediaSubType()
812
813```
814MediaLibrary_ErrorCode OH_MediaAsset_GetMediaSubType(OH_MediaAsset* mediaAsset, MediaLibrary_MediaSubType* mediaSubType)
815```
816**Description**<br>
817Obtains the subtype of a media asset.
818
819**Since**: 13
820
821**Parameters**
822
823| Name| Description|
824| -------- | -------- |
825| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
826| mediaSubType | Pointer to the media asset subtype obtained. |
827
828**Returns**
829
830[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
831
832- **MEDIA_LIBRARY_OK**: The operation is successful.
833
834- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
835  Possible causes:
836  1. There is mandatory parameter that is not specified.
837  2. The parameter type is incorrect.
838  3. The parameter verification failed.
839
840- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
841
842### OH_MediaAsset_GetMediaType()
843
844```
845MediaLibrary_ErrorCode OH_MediaAsset_GetMediaType(OH_MediaAsset* mediaAsset, MediaLibrary_MediaType* mediaType)
846```
847**Description**<br>
848Obtains the type of a media asset.
849
850**Since**: 13
851
852**Parameters**
853
854| Name| Description|
855| -------- | -------- |
856| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
857| mediaType | Pointer to the media asset type obtained. |
858
859**Returns**
860
861[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
862
863- **MEDIA_LIBRARY_OK**: The operation is successful.
864
865- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
866  Possible causes:
867  1. There is mandatory parameter that is not specified.
868  2. The parameter type is incorrect.
869  3. The parameter verification failed.
870
871- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
872
873
874### OH_MediaAsset_GetOrientation()
875
876```
877MediaLibrary_ErrorCode OH_MediaAsset_GetOrientation(OH_MediaAsset* mediaAsset, uint32_t* orientation)
878```
879**Description**<br>
880Obtains the orientation of a media asset, in degrees.
881
882**Since**: 12
883
884**Parameters**
885
886| Name| Description|
887| -------- | -------- |
888| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
889| orientation | Pointer to the orientation of the image obtained, in degrees. |
890
891**Returns**
892
893[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
894
895- **MEDIA_LIBRARY_OK**: The operation is successful.
896
897- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
898  Possible causes:
899  1. There is mandatory parameter that is not specified.
900  2. The parameter type is incorrect.
901  3. The parameter verification failed.
902
903- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
904
905
906### OH_MediaAsset_GetSize()
907
908```
909MediaLibrary_ErrorCode OH_MediaAsset_GetSize(OH_MediaAsset* mediaAsset, uint32_t* size)
910```
911**Description**<br>
912Obtains the size of a media asset file.
913
914**Since**: 12
915
916**Parameters**
917
918| Name| Description|
919| -------- | -------- |
920| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
921| size | Pointer to the file size obtained, in bytes. |
922
923**Returns**
924
925[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
926
927- **MEDIA_LIBRARY_OK**: The operation is successful.
928
929- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
930  Possible causes:
931  1. There is mandatory parameter that is not specified.
932  2. The parameter type is incorrect.
933  3. The parameter verification failed.
934
935- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
936
937
938### OH_MediaAsset_GetTitle()
939
940```
941MediaLibrary_ErrorCode OH_MediaAsset_GetTitle(OH_MediaAsset* mediaAsset, const char** title)
942```
943**Description**<br>
944Obtains the title of a media asset.
945
946**Since**: 13
947
948**Parameters**
949
950| Name| Description|
951| -------- | -------- |
952| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
953| title | Pointer to the media asset title obtained. |
954
955**Returns**
956
957[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
958
959- **MEDIA_LIBRARY_OK**: The operation is successful.
960
961- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
962  Possible causes:
963  1. There is mandatory parameter that is not specified.
964  2. The parameter type is incorrect.
965  3. The parameter verification failed.
966
967- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
968
969
970### OH_MediaAsset_GetUri()
971
972```
973MediaLibrary_ErrorCode OH_MediaAsset_GetUri(OH_MediaAsset* mediaAsset, const char** uri)
974```
975**Description**<br>
976Obtains the URI of a media asset.
977
978**Since**: 12
979
980**Parameters**
981
982| Name| Description|
983| -------- | -------- |
984| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
985| uri | Pointer to the URI obtained. |
986
987**Returns**
988
989[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
990
991- **MEDIA_LIBRARY_OK**: The operation is successful.
992
993- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
994  Possible causes:
995  1. There is mandatory parameter that is not specified.
996  2. The parameter type is incorrect.
997  3. The parameter verification failed.
998
999- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1000
1001
1002### OH_MediaAsset_GetWidth()
1003
1004```
1005MediaLibrary_ErrorCode OH_MediaAsset_GetWidth(OH_MediaAsset* mediaAsset, uint32_t* width)
1006```
1007**Description**<br>
1008Obtains the image width (in pixels) of a media asset.
1009
1010**Since**: 12
1011
1012**Parameters**
1013
1014| Name| Description|
1015| -------- | -------- |
1016| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
1017| width | Pointer to the image width obtained, in pixels. |
1018
1019**Returns**
1020
1021[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1022
1023- **MEDIA_LIBRARY_OK**: The operation is successful.
1024
1025- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1026  Possible causes:
1027  1. There is mandatory parameter that is not specified.
1028  2. The parameter type is incorrect.
1029  3. The parameter verification failed.
1030
1031- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1032
1033
1034### OH_MediaAsset_IsFavorite()
1035
1036```
1037MediaLibrary_ErrorCode OH_MediaAsset_IsFavorite(OH_MediaAsset* mediaAsset, uint32_t* favorite)
1038```
1039**Description**<br>
1040Checks whether a media asset is favorited.
1041
1042**Since**: 13
1043
1044**Parameters**
1045
1046| Name| Description|
1047| -------- | -------- |
1048| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
1049| favorite | Pointer to the favorite status obtained. |
1050
1051**Returns**
1052
1053[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1054
1055- **MEDIA_LIBRARY_OK**: The operation is successful.
1056
1057- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1058  Possible causes:
1059  1. There is mandatory parameter that is not specified.
1060  2. The parameter type is incorrect.
1061  3. The parameter verification failed.
1062
1063- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1064
1065
1066### OH_MediaAsset_Release()
1067
1068```
1069MediaLibrary_ErrorCode OH_MediaAsset_Release(OH_MediaAsset* mediaAsset)
1070```
1071**Description**<br>
1072Releases a media asset.
1073
1074**Since**: 12
1075
1076**Parameters**
1077
1078| Name| Description|
1079| -------- | -------- |
1080| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
1081
1082**Returns**
1083
1084[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1085
1086- **MEDIA_LIBRARY_OK**: The operation is successful.
1087
1088- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1089  Possible causes:
1090  1. There is mandatory parameter that is not specified.
1091  2. The parameter type is incorrect.
1092  3. The parameter verification failed.
1093
1094- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1095
1096
1097### OH_MediaAssetChangeRequest_AddResourceWithBuffer()
1098
1099```
1100MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_AddResourceWithBuffer(OH_MediaAssetChangeRequest* changeRequest, MediaLibrary_ResourceType resourceType, uint8_t* buffer, uint32_t length)
1101```
1102**Description**<br>
1103Adds a resource using **ArrayBuffer** data.
1104
1105**Since**: 12
1106
1107**Parameters**
1108
1109| Name| Description|
1110| -------- | -------- |
1111| changeRequest | Pointer to the [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance. |
1112| resourceType | [MediaLibrary_ResourceType](#medialibrary_resourcetype) of the resource to add. |
1113| buffer | Pointe to the data buffer. |
1114| length | Length of the data buffer. |
1115
1116**Returns**
1117
1118[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1119
1120- **MEDIA_LIBRARY_OK**: The operation is successful.
1121
1122- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1123  Possible causes:
1124  1. There is mandatory parameter that is not specified.
1125  2. The parameter type is incorrect.
1126  3. The parameter verification failed.
1127
1128- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1129
1130
1131### OH_MediaAssetChangeRequest_AddResourceWithUri()
1132
1133```
1134MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_AddResourceWithUri(OH_MediaAssetChangeRequest* changeRequest, MediaLibrary_ResourceType resourceType, char* fileUri)
1135```
1136**Description**<br>
1137Adds a media asset of the given URI.
1138
1139**Since**: 13
1140
1141**Parameters**
1142
1143| Name| Description|
1144| -------- | -------- |
1145| changeRequest | Pointer to the [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance. |
1146| resourceType | [MediaLibrary_ResourceType](#medialibrary_resourcetype) of the resource to add. |
1147| fileUri | URI of the file to add. |
1148
1149**Returns**
1150
1151[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1152
1153- **MEDIA_LIBRARY_OK**: The operation is successful.
1154
1155- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1156  Possible causes:
1157  1. There is mandatory parameter that is not specified.
1158  2. The parameter type is incorrect.
1159  3. The parameter verification failed.
1160
1161- **MEDIA_LIBRARY_NO_SUCH_FILE**: The file does not exist.
1162
1163- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1164
1165- **MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED**: This operation is not supported.
1166
1167
1168### OH_MediaAssetChangeRequest_Create()
1169
1170```
1171OH_MediaAssetChangeRequest* OH_MediaAssetChangeRequest_Create(OH_MediaAsset* mediaAsset)
1172```
1173**Description**<br>
1174Creates an [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance.
1175
1176**Since**: 12
1177
1178**Parameters**
1179
1180| Name| Description|
1181| -------- | -------- |
1182| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance. |
1183
1184**Returns**
1185
1186[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1187
1188- **MEDIA_LIBRARY_OK**: The operation is successful.
1189
1190- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1191  Possible causes:
1192  1. There is mandatory parameter that is not specified.
1193  2. The parameter type is incorrect.
1194  3. The parameter verification failed.
1195
1196- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1197
1198
1199### OH_MediaAssetChangeRequest_DiscardCameraPhoto()
1200
1201```
1202MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_DiscardCameraPhoto(OH_MediaAssetChangeRequest* changeRequest)
1203```
1204**Description**<br>
1205Discards the photo taken by the camera.
1206
1207**Since**: 12
1208
1209**Parameters**
1210
1211| Name| Description|
1212| -------- | -------- |
1213| changeRequest | Pointer to the [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance. |
1214
1215**Returns**
1216
1217[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1218
1219- **MEDIA_LIBRARY_OK**: The operation is successful.
1220
1221- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1222  Possible causes:
1223  1. There is mandatory parameter that is not specified.
1224  2. The parameter type is incorrect.
1225  3. The parameter verification failed.
1226
1227- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1228
1229- **MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED**: This operation is not supported.
1230
1231
1232### OH_MediaAssetChangeRequest_GetWriteCacheHandler()
1233
1234```
1235MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_GetWriteCacheHandler(OH_MediaAssetChangeRequest* changeRequest, int32_t* fd)
1236```
1237**Description**<br>
1238Obtains the handler used for writing a file to cache.
1239
1240**Since**: 13
1241
1242**Parameters**
1243
1244| Name| Description|
1245| -------- | -------- |
1246| changeRequest | Pointer to the [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance. |
1247| fd | Pointer to the file descriptor (FD) obtained. |
1248
1249**Required permissions**
1250
1251ohos.permission.WRITE_IMAGEVIDEO
1252
1253**Returns**
1254
1255[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1256
1257- **MEDIA_LIBRARY_OK**: The operation is successful.
1258
1259- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1260  Possible causes:
1261  1. There is mandatory parameter that is not specified.
1262  2. The parameter type is incorrect.
1263  3. The parameter verification failed.
1264
1265- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1266
1267- **MEDIA_LIBRARY_PERMISSION_DENIED**: The access is denied due to lack of permission.
1268
1269- **MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED**: This operation is not supported.
1270
1271
1272### OH_MediaAssetChangeRequest_Release()
1273
1274```
1275MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_Release(OH_MediaAssetChangeRequest* changeRequest)
1276```
1277**Description**<br>
1278Releases an [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance.
1279
1280**Since**: 12
1281
1282**Parameters**
1283
1284| Name| Description|
1285| -------- | -------- |
1286| changeRequest | Pointer to the [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance. |
1287
1288**Returns**
1289
1290[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1291
1292- **MEDIA_LIBRARY_OK**: The operation is successful.
1293
1294- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1295  Possible causes:
1296  1. There is mandatory parameter that is not specified.
1297  2. The parameter type is incorrect.
1298  3. The parameter verification failed.
1299
1300
1301### OH_MediaAssetChangeRequest_SaveCameraPhoto()
1302
1303```
1304MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_SaveCameraPhoto(OH_MediaAssetChangeRequest* changeRequest, MediaLibrary_ImageFileType imageFileType)
1305```
1306**Description**<br>
1307Saves the photo taken by the camera.
1308
1309**Since**: 12
1310
1311**Parameters**
1312
1313| Name| Description|
1314| -------- | -------- |
1315| changeRequest | Pointer to the [OH_MediaAssetChangeRequest](#oh_mediaassetchangerequest) instance. |
1316| imageFileType | [MediaLibrary_ImageFileType](#medialibrary_imagefiletype) of the photo to save. |
1317
1318**Returns**
1319
1320[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1321
1322- **MEDIA_LIBRARY_OK**: The operation is successful.
1323
1324- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1325  Possible causes:
1326  1. There is mandatory parameter that is not specified.
1327  2. The parameter type is incorrect.
1328  3. The parameter verification failed.
1329
1330- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1331
1332- **MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED**: This operation is not supported.
1333
1334
1335### OH_MediaAssetManager_CancelRequest()
1336
1337```
1338bool OH_MediaAssetManager_CancelRequest(OH_MediaAssetManager* manager, const MediaLibrary_RequestId requestId)
1339```
1340**Description**<br>
1341Cancels a request based on the request ID.
1342
1343**Since**: 12
1344
1345**Parameters**
1346
1347| Name| Description|
1348| -------- | -------- |
1349| manager | Pointer to the **OH_MediaAssetManager** instance. |
1350| requestId | ID of the request to cancel. |
1351
1352**Required permissions**
1353
1354ohos.permission.READ_IMAGEVIDEO
1355
1356**Returns**
1357
1358Returns **true** if the request is successfully canceled; returns **false** otherwise.
1359
1360
1361### OH_MediaAssetManager_Create()
1362
1363```
1364OH_MediaAssetManager* OH_MediaAssetManager_Create(void)
1365```
1366**Description**<br>
1367Creates a **MediaAssetManager** instance.
1368
1369**Since**: 12
1370
1371**Returns**
1372
1373Returns the pointer to the **MediaAssetManager** instance created.
1374
1375
1376### OH_MediaAssetManager_Release()
1377
1378```
1379MediaLibrary_ErrorCode OH_MediaAssetManager_Release(OH_MediaAssetManager* manager)
1380```
1381**Description**<br>
1382Releases an [OH_MediaAssetManager](#oh_mediaassetmanager) instance.
1383
1384**Since**: 13
1385
1386**Parameters**
1387
1388| Name| Description|
1389| -------- | -------- |
1390| manager | Pointer to the [OH_MediaAssetManager](#oh_mediaassetmanager) instance to release. |
1391
1392**Returns**
1393
1394[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1395
1396- **MEDIA_LIBRARY_OK**: The operation is successful.
1397
1398- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1399  Possible causes:
1400  1. There is mandatory parameter that is not specified.
1401  2. The parameter type is incorrect.
1402  3. The parameter verification failed.
1403
1404
1405### OH_MediaAssetManager_RequestImage()
1406
1407```
1408MediaLibrary_ErrorCode OH_MediaAssetManager_RequestImage(OH_MediaAssetManager* manager, OH_MediaAsset* mediaAsset, MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId, OH_MediaLibrary_OnImageDataPrepared callback)
1409```
1410**Description**<br>
1411Requests an image.
1412
1413**Since**: 12
1414
1415**Parameters**
1416
1417| Name| Description|
1418| -------- | -------- |
1419| manager | Pointer to the [OH_MediaAssetManager](#oh_mediaassetmanager) instance. |
1420| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance to be requested. |
1421| requestOptions | [MediaLibrary_RequestOptions](_media_library___request_options.md). |
1422| requestId | Pointer to the [MediaLibrary_RequestId](_media_library___request_id.md) obtained. |
1423| callback | Callback [OH_MediaLibrary_OnImageDataPrepared](#oh_medialibrary_onimagedataprepared) to be invoked when the requested image source is ready. |
1424
1425**Required permissions**
1426
1427ohos.permission.READ_IMAGEVIDEO
1428
1429**Returns**
1430
1431[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1432
1433- **MEDIA_LIBRARY_OK**: The operation is successful.
1434
1435- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1436  Possible causes:
1437  1. There is mandatory parameter that is not specified.
1438  2. The parameter type is incorrect.
1439  3. The parameter verification failed.
1440- **MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED**: This operation is not supported.
1441
1442- **MEDIA_LIBRARY_PERMISSION_DENIED**: The access is denied due to lack of permission.
1443
1444- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1445
1446
1447### OH_MediaAssetManager_RequestImageForPath()
1448
1449```
1450MediaLibrary_RequestId OH_MediaAssetManager_RequestImageForPath(OH_MediaAssetManager* manager, const char* uri, MediaLibrary_RequestOptions requestOptions, const char* destPath, OH_MediaLibrary_OnDataPrepared callback)
1451```
1452**Description**<br>
1453Requests an image in the specified directory.
1454
1455**Since**: 12
1456
1457**Parameters**
1458
1459| Name| Description|
1460| -------- | -------- |
1461| manager | Pointer to the **OH_MediaAssetManager** instance. |
1462| uri | Pointer to the URI of the requested image asset. |
1463| requestOptions | Options related to the image asset quality and delivery mode. |
1464| destPath | Pointer to the destination directory of the requested image asset. |
1465| callback | Callback to be invoked when the requested image asset is ready. |
1466
1467**Required permissions**
1468
1469ohos.permission.READ_IMAGEVIDEO
1470
1471**Returns**
1472
1473Returns the request ID.
1474
1475
1476### OH_MediaAssetManager_RequestMovingPhoto()
1477
1478```
1479MediaLibrary_ErrorCode OH_MediaAssetManager_RequestMovingPhoto(OH_MediaAssetManager* manager, OH_MediaAsset* mediaAsset, MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId, OH_MediaLibrary_OnMovingPhotoDataPrepared callback)
1480```
1481**Description**<br>
1482Requests moving photo resources based on different policies.
1483
1484**Since**: 13
1485
1486**Parameters**
1487
1488| Name| Description|
1489| -------- | -------- |
1490| manager | Pointer to the [OH_MediaAssetManager](#oh_mediaassetmanager) instance. |
1491| mediaAsset | Pointer to the [OH_MediaAsset](#oh_mediaasset) instance to be requested. |
1492| requestOptions | [MediaLibrary_RequestOptions](_media_library___request_options.md). |
1493| requestId | Pointer to the [MediaLibrary_RequestId](_media_library___request_id.md) obtained. |
1494| callback | [OH_MediaLibrary_OnMovingPhotoDataPrepared](#oh_medialibrary_onmovingphotodataprepared) to be called when the requested moving photo is ready. |
1495
1496**Required permissions**
1497
1498ohos.permission.READ_IMAGEVIDEO
1499
1500**Returns**
1501
1502[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1503
1504- **MEDIA_LIBRARY_OK**: The operation is successful.
1505
1506- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1507  Possible causes:
1508  1. There is mandatory parameter that is not specified.
1509  2. The parameter type is incorrect.
1510  3. The parameter verification failed.
1511- **MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED**: This operation is not supported.
1512
1513- **MEDIA_LIBRARY_PERMISSION_DENIED**: The access is denied due to lack of permission.
1514
1515- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1516
1517
1518### OH_MediaAssetManager_RequestVideoForPath()
1519
1520```
1521MediaLibrary_RequestId OH_MediaAssetManager_RequestVideoForPath(OH_MediaAssetManager* manager, const char* uri, MediaLibrary_RequestOptions requestOptions, const char* destPath, OH_MediaLibrary_OnDataPrepared callback)
1522```
1523**Description**<br>
1524Requests a video asset in the specified directory.
1525
1526**Since**: 12
1527
1528**Parameters**
1529
1530| Name| Description|
1531| -------- | -------- |
1532| manager | Pointer to the **OH_MediaAssetManager** instance. |
1533| uri | Pointer to the URI of the requested video asset. |
1534| requestOptions | Options related to the image asset quality and delivery mode. |
1535| destPath | Pointer to the destination directory of the requested image asset. |
1536| callback | Callback to be invoked when the requested image asset is ready. |
1537
1538**Required permissions**
1539
1540ohos.permission.READ_IMAGEVIDEO
1541
1542**Returns**
1543
1544Returns the request ID.
1545
1546
1547### OH_MovingPhoto_GetUri()
1548
1549```
1550MediaLibrary_ErrorCode OH_MovingPhoto_GetUri(OH_MovingPhoto* movingPhoto, const char** uri)
1551```
1552**Description**<br>
1553Obtains the URI of a moving photo.
1554
1555**Since**: 13
1556
1557**Parameters**
1558
1559| Name| Description|
1560| -------- | -------- |
1561| movingPhoto | Pointer to the [OH_MovingPhoto](#oh_movingphoto) instance. |
1562| uri | Double pointer to the URI of the moving photo obtained. |
1563
1564**Returns**
1565
1566[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1567
1568- **MEDIA_LIBRARY_OK**: The operation is successful.
1569
1570- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1571  Possible causes:
1572  1. There is mandatory parameter that is not specified.
1573  2. The parameter type is incorrect.
1574  3. The parameter verification failed.
1575
1576- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1577
1578
1579### OH_MovingPhoto_Release()
1580
1581```
1582MediaLibrary_ErrorCode OH_MovingPhoto_Release(OH_MovingPhoto* movingPhoto)
1583```
1584**Description**<br>
1585Releases an [OH_MovingPhoto](#oh_movingphoto) instance.
1586
1587**Since**: 13
1588
1589**Parameters**
1590
1591| Name| Description|
1592| -------- | -------- |
1593| movingPhoto | Pointer to the [OH_MovingPhoto](#oh_movingphoto) instance to release. |
1594
1595**Returns**
1596
1597[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1598
1599- **MEDIA_LIBRARY_OK**: The operation is successful.
1600
1601- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1602  Possible causes:
1603  1. There is mandatory parameter that is not specified.
1604  2. The parameter type is incorrect.
1605  3. The parameter verification failed.
1606
1607
1608### OH_MovingPhoto_RequestContentWithBuffer()
1609
1610```
1611MediaLibrary_ErrorCode OH_MovingPhoto_RequestContentWithBuffer(OH_MovingPhoto* movingPhoto, MediaLibrary_ResourceType resourceType, const uint8_t** buffer, uint32_t* size)
1612```
1613**Description**<br>
1614Requests the moving photo content of the specified resource type and returns it in ArrayBuffer format.
1615
1616**Since**: 13
1617
1618**Parameters**
1619
1620| Name| Description|
1621| -------- | -------- |
1622| movingPhoto | Pointer to the [OH_MovingPhoto](#oh_movingphoto) instance. |
1623| resourceType | [MediaLibrary_ResourceType](#medialibrary_resourcetype) of the moving photo. |
1624| buffer | Double pointer to the buffer for storing the target file data. |
1625| size | Pointer to the buffer size. |
1626
1627**Required permissions**
1628
1629ohos.permission.READ_IMAGEVIDEO
1630
1631**Returns**
1632
1633[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1634
1635- **MEDIA_LIBRARY_OK**: The operation is successful.
1636
1637- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1638  Possible causes:
1639  1. There is mandatory parameter that is not specified.
1640  2. The parameter type is incorrect.
1641  3. The parameter verification failed.
1642
1643- **MEDIA_LIBRARY_PERMISSION_DENIED**: The access is denied due to lack of permission.
1644
1645- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1646
1647
1648### OH_MovingPhoto_RequestContentWithUri()
1649
1650```
1651MediaLibrary_ErrorCode OH_MovingPhoto_RequestContentWithUri(OH_MovingPhoto* movingPhoto, MediaLibrary_ResourceType resourceType, char* uri)
1652```
1653**Description**<br>
1654Requests the moving photo content of the specified resource type and writes it to the specified URI.
1655
1656**Since**: 13
1657
1658**Parameters**
1659
1660| Name| Description|
1661| -------- | -------- |
1662| movingPhoto | Pointer to the [OH_MovingPhoto](#oh_movingphoto) instance. |
1663| resourceType | [MediaLibrary_ResourceType](#medialibrary_resourcetype) of the moving photo. |
1664| uri | Pointer to the URI of the file, to which the data is written. |
1665
1666**Required permissions**
1667
1668ohos.permission.READ_IMAGEVIDEO
1669
1670**Returns**
1671
1672[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1673
1674- **MEDIA_LIBRARY_OK**: The operation is successful.
1675
1676- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1677  Possible causes:
1678  1. There is mandatory parameter that is not specified.
1679  2. The parameter type is incorrect.
1680  3. The parameter verification failed.
1681
1682- **MEDIA_LIBRARY_PERMISSION_DENIED**: The access is denied due to lack of permission.
1683
1684- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1685
1686
1687### OH_MovingPhoto_RequestContentWithUris()
1688
1689```
1690MediaLibrary_ErrorCode OH_MovingPhoto_RequestContentWithUris(OH_MovingPhoto* movingPhoto, char* imageUri, char* videoUri)
1691```
1692**Description**<br>
1693Requests the image data and video data of a moving photo and writes them to the specified URIs, respectively.
1694
1695**Since**: 13
1696
1697**Parameters**
1698
1699| Name| Description|
1700| -------- | -------- |
1701| movingPhoto | Pointer to the [OH_MovingPhoto](#oh_movingphoto) instance. |
1702| imageUri | Pointer to the URI of the file, to which the image data is written. |
1703| videoUri | Pointer to the URI of the file, to which the video data is written. |
1704
1705**Required permissions**
1706
1707ohos.permission.READ_IMAGEVIDEO
1708
1709**Returns**
1710
1711[MediaLibrary_ErrorCode](#medialibrary_errorcode-1):
1712
1713- **MEDIA_LIBRARY_OK**: The operation is successful.
1714
1715- **MEDIA_LIBRARY_PARAMETER_ERROR**: Incorrect parameters.
1716  Possible causes:
1717  1. There is mandatory parameter that is not specified.
1718  2. The parameter type is incorrect.
1719  3. The parameter verification failed.
1720
1721- **MEDIA_LIBRARY_PERMISSION_DENIED**: The access is denied due to lack of permission.
1722
1723- **MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR**: An internal system error occurred.
1724