> - The APIs of this module are supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
> - This API is deprecated since API version 9 and will be retained until API version 13.
> - Certain functionalities are changed as system APIs and can be used only by system applications. To use these functionalities, call [@ohos.filemanagement.userFileManager](js-apis-userFileManager.md).
> - The functionalities for selecting and storing media assets are still open to common applications. To use these functionalities, call [@ohos.file.picker](js-apis-file-picker.md).
> - The APIs of this module are deprecated since API version 9 and will be retained until API version 13.
> - Some APIs are changed as system APIs and can be used only by system applications. Use [@ohos.filemanagement.userFileManager](js-apis-userFileManager.md) instead.
> - The APIs for selecting and storing media assets are still open to common applications. Use [@ohos.file.picker](js-apis-file-picker.md) instead.
Obtains file assets (also called files). This API uses an asynchronous callback to return the result.
> **NOTE**
> From API version 10, the albums represented by physical directories are replaced by logical albums, which allows multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
// Check whether the result set of the obtained files is undefined. If yes, the API call fails.
if(fetchFileResult==undefined){
console.error('get fetchFileResult failed with error: '+error);
return;
}
// Obtain the total number of files in the result set.
constcount=fetchFileResult.getCount();
// Check whether the number is less than 0. If yes, the API call fails.
if(count<0){
console.error('get count from fetchFileResult failed, count: '+count);
return;
}
// Check whether the number is 0. If yes, the API call is successful, but the result set is empty. Check whether the options for fetching the files are correctly set and whether the corresponding files exist on the device.
if(count==0){
console.info('The count of fetchFileResult is zero');
// Check whether the result set of the obtained files is undefined. If yes, the API call fails.
if(fetchFileResult==undefined){
console.error('get fetchFileResult failed with error: '+error);
return;
}
// Obtain the total number of files in the result set.
constcount=fetchFileResult.getCount();
// Check whether the number is less than 0. If yes, the API call fails.
if(count<0){
console.error('get count from fetchFileResult failed, count: '+count);
return;
}
// Check whether the number is 0. If yes, the API call is successful, but the result set is empty. Check whether the options for fetching the files are correctly set and whether the corresponding files exist on the device.
if(count==0){
console.info('The count of fetchFileResult is zero');
Obtains file assets. This API uses a promise to return the result.
> **NOTE**
> From API version 10, the albums represented by physical directories are replaced by logical albums, which allows multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
// Obtain the total number of files in the result set.
constcount=fetchFileResult.getCount();
// Check whether the number is less than 0. If yes, the API call fails.
if(count<0){
console.error('get count from fetchFileResult failed, count: '+count);
return;
}
// Check whether the number is 0. If yes, the API call is successful, but the result set is empty. Check whether the options for fetching the files are correctly set and whether the corresponding files exist on the device.
if(count==0){
console.info('The count of fetchFileResult is zero');
// Obtain the total number of files in the result set.
constcount=fetchFileResult.getCount();
// Check whether the number is less than 0. If yes, the API call fails.
if(count<0){
console.error('get count from fetchFileResult failed, count: '+count);
return;
}
// Check whether the number is 0. If yes, the API call is successful, but the result set is empty. Check whether the options for fetching the files are correctly set and whether the corresponding files exist on the device.
if(count==0){
console.info('The count of fetchFileResult is zero');
| type | 'deviceChange'|<br>'albumChange'|<br>'imageChange'|<br>'audioChange'|<br>'videoChange'|<br>'fileChange'|<br>'remoteFileChange' | Yes | Type of the event to subscribe to.<br>'deviceChange': registered device change<br>'albumChange': album change<br>'imageChange': image file change<br>'audioChange': audio file change<br>'videoChange': video file change<br>'fileChange': file change<br>'remoteFileChange': file change on the registered device|
| callback | Callback<void> | Yes | Callback that returns no value. |
| type | 'deviceChange'|<br>'albumChange'|<br>'imageChange'|<br>'audioChange'|<br>'videoChange'|<br>'fileChange'|<br>'remoteFileChange' | Yes | Media type.<br>'deviceChange': registered device change<br>'albumChange': album change<br>'imageChange': image file change<br>'audioChange': audio file change<br>'videoChange': video file change<br>'fileChange': file change<br>'remoteFileChange': file change on the registered device|
| callback | Callback<void> | No | Void callback. |
| type | 'deviceChange'|<br>'albumChange'|<br>'imageChange'|<br>'audioChange'|<br>'videoChange'|<br>'fileChange'|<br>'remoteFileChange' | Yes | Type of the event to unsubscribe from.<br>'deviceChange': registered device change<br>'albumChange': album change<br>'imageChange': image file change<br>'audioChange': audio file change<br>'videoChange': video file change<br>'fileChange': file change<br>'remoteFileChange': file change on the registered device|
| callback | Callback<void> | No | Callback that returns no value. |
Creates a media asset. This API uses an asynchronous callback to return the result.
> **NOTE**
> From the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
| relativePath | string | Yes | Path for storing the file. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the paths for storing different types of files.|
Creates a media asset. This API uses a promise to return the result.
> **NOTE**
> From the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
| relativePath | string | Yes | Relative path. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the relative path of the level-1 directory of different types of media files.|
| displayName | string | Yes | File name to display. |
| relativePath | string | Yes | Relative path of the file, which can be obtained by [getPublicDirectory](#getpublicdirectory8).|
**Return value**
| Type | Description |
| ------------------------ | ----------------- |
| [FileAsset](#fileasset7) | Media data (FileAsset).|
| Promise<[FileAsset](#fileasset7)> | Promise used to return the **FileAsset** instance created.|
Obtains the albums. This API uses an asynchronous callback to return the result.
Obtains albums. This API uses an asynchronous callback to return the result.
> **NOTE**
> From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For more details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
Obtains the albums. This API uses a promise to return the result.
Obtains albums. This API uses a promise to return the result.
> **NOTE**
> From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For more details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the result.
> **NOTE**
> This API is supported since API version 6 and can be used only by the FA model.
> You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead.The **\<Image>** component can be used to render and display local and online images.
> This API is supported since API version 6 and can be used only in the FA model.
> You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead.<br>The **\<Image>** component can be used to render and display local and online images.
Starts image preview. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
Starts image preview. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the result.
> **NOTE**
> This API is supported since API version 6 and can be used only by the FA model.
> You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead.The **\<Image>** component can be used to render and display local and online images.
> This API is supported since API version 6 and can be used only in the FA model.
> You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead.<br>The **\<Image>** component can be used to render and display local and online images.
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses a promise to return the execution result.
> **NOTE**
> This API is supported since API version 6 and can be used only by the FA model.
> You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead.The **\<Image>** component can be used to render and display local and online images.
> This API is supported since API version 6 and can be used only in the FA model.
> You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead.<br>The **\<Image>** component can be used to render and display local and online images.
Starts media selection. This API uses an asynchronous callback to return the list of URIs that store the selected media assets.
Starts media selection. This API uses an asynchronous callback to return the URIs of the selected media assets.
> **NOTE**
> This API is supported since API version 6 and can be used only by the FA model.
> You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
> This API is supported since API version 6 and can be used only in the FA model.
> You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, see [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the list of URIs (starting with **datashare://**) that store the selected media assets.|
| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the URIs of the selected media assets.|
Starts media selection. This API uses a promise to return the list of URIs that store the selected media assets.
Starts media selection. This API uses a promise to return the URIs of the selected media assets.
> **NOTE**
> This API is supported since API version 6 and can be used only by the FA model.
> You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
> This API is supported since API version 6 and can be used only in the FA model.
> You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, see [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos).
Obtains information about online peer devices. This API uses an asynchronous callback to return the result.
Obtains information about all peer devices. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
...
...
@@ -1016,19 +1025,19 @@ Obtains information about online peer devices. This API uses an asynchronous cal
| Type | Description |
| ------------------- | -------------------- |
| callback: AsyncCallback\<Array\<[PeerInfo](#peerinfo8)>> | Promise used to return all peer devices, in an array of **PeerInfo** objects.|
| callback: AsyncCallback\<Array\<[PeerInfo](#peerinfo8)>> | Callback invoked to return all peer devices, in an array of **PeerInfo** objects.|
**Example**
```js
asyncfunctionexample(){
media.getAllPeers((error,devicesInfo)=>{
if(devicesInfo!=undefined){
console.info('get distributed info '+JSON.stringify(devicesInfo));
}else{
console.error('get distributed failed with error: '+error);
}
});
media.getAllPeers((error,devicesInfo)=>{
if(devicesInfo!=undefined){
console.info('get distributed info '+JSON.stringify(devicesInfo));
}else{
console.error('get distributed failed with error: '+error);
}
});
}
```
...
...
@@ -1037,6 +1046,7 @@ async function example() {
Provides APIs for encapsulating file asset attributes.
> **NOTE**
>
> 1. The system attempts to parse the file content if the file is an audio or video file. The actual field values will be restored from the passed values during scanning on some devices.
> 2. Some devices may not support the modification of **orientation**. You are advised to use [ModifyImageProperty](js-apis-image.md#modifyimageproperty9) of the **image** module.
| mediaType<sup>8+</sup> | [MediaType](#mediatype8) | Yes | No | Media type. |
| displayName | string | Yes | Yes | Display file name, including the file name extension. |
| title | string | Yes | Yes | Title in the file. By default, it carries the file name without extension. |
| relativePath<sup>8+</sup> | string | Yes | Yes | Relative public directory of the file. |
| parent<sup>8+</sup> | number | Yes | No | Parent directory ID. |
| displayName | string | Yes | Yes | File name, including the file name extension, to display. |
| title | string | Yes | Yes | Title in the file. |
| relativePath<sup>8+</sup> | string | Yes | Yes | Relative path of the user directory. |
| parent<sup>8+</sup> | number | Yes | No | Parent directory ID. Since SDK of API version 10, an asset can exist in multiple albums. Therefore, this attribute is incompatible. The obtained value is always **0**. |
| size | number | Yes | No | File size, in bytes. |
| dateAdded | number | Yes | No | Date when the file was added. The value is the number of seconds elapsed since the Epoch time. |
| dateModified | number | Yes | No | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
| height | number | Yes | No | Image height, in pixels. |
| orientation | number | Yes | Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees).|
| duration<sup>8+</sup> | number | Yes | No | Duration, in ms. |
| albumId | number | Yes | No | ID of the album to which the file belongs. |
| albumUri<sup>8+</sup> | string | Yes | No | URI of the album to which the file belongs. |
| albumName | string | Yes | No | Name of the album to which the file belongs. |
| albumId | number | Yes | No | ID of the album to which the file belongs. Since SDK of API version 10, an asset can exist in multiple albums. Therefore, this attribute is incompatible. The obtained value is always **0**. |
| albumUri<sup>8+</sup> | string | Yes | No | URI of the album to which the file belongs. Since SDK of API version 10, an asset can exist in multiple albums. Therefore, this attribute is incompatible. The obtained value is always an empty string. |
| albumName | string | Yes | No | Name of the album to which the file belongs. Since SDK of API version 10, an asset can exist in multiple albums. Therefore, this attribute is incompatible. The obtained value is always an empty string. |
### isDirectory<sup>8+</sup>
...
...
@@ -1083,29 +1092,29 @@ Checks whether this file asset is a directory. This API uses an asynchronous cal
| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the file asset is a directory.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the file asset is a directory; the value false means the opposite.|
| Promise<boolean> | Promise used to return whether the file asset is a directory.|
| Promise<boolean> | Promise used to return the result. The value **true** means the file asset is a directory; the value **false** means the opposite.|
Commits the modification in this file asset to the database. This API uses an asynchronous callback to return the result.
Commits the modification on the file metadata to the database. This API uses an asynchronous callback to return the result.
> **NOTE**
> Since the SDK of API version 10, **audio** does not have the **orientation** attribute. Therefore, the **orientation** attribute of the audio resource cannot be modified by **commitModify()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
...
...
@@ -1161,26 +1173,26 @@ Commits the modification in this file asset to the database. This API uses an as
Commits the modification in this file asset to the database. This API uses a promise to return the result.
Commits the modification on the file asset to the database. This API uses a promise to return the result.
> **NOTE**
> Since the SDK of API version 10, **audio** does not have the **orientation** attribute. Therefore, the **orientation** attribute of the audio resource cannot be modified by **commitModify()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
...
...
@@ -1198,24 +1213,24 @@ Commits the modification in this file asset to the database. This API uses a pro
| Type | Description |
| ------------------- | ---------- |
| Promise<void> | Void promise.|
| Promise<void> | Promise that returns no value.|
Opens this file asset. This API uses an asynchronous callback to return the result.
**NOTE**: When a file is opened in 'w' mode, the returned FD cannot be read. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode. The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
**NOTE**<br>If a file is opened in 'w' mode, the returned file descriptor (FD) cannot be used to read the file. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode. The write operations are mutually exclusive. After a write operation is complete, you must call **close** to close the file.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
...
...
@@ -1235,24 +1250,24 @@ Opens this file asset. This API uses an asynchronous callback to return the resu
Opens this file asset. This API uses a promise to return the result.
**NOTE**: When a file is opened in 'w' mode, the returned FD cannot be read. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode. The write operations are mutually exclusive. After a write operation is complete, you must call **close** to release the resource.
**NOTE**<br>If a file is opened in 'w' mode, the returned FD cannot be used to read the file. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode. The write operations are mutually exclusive. After a write operation is complete, you must call **close** to close the file.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
...
...
@@ -1272,27 +1287,27 @@ Opens this file asset. This API uses a promise to return the result.
| isFavorite | boolean | Yes | Whether to favorite or unfavorite the file. The value **true** means to favorite the file, and **false** means to unfavorite the file.|
| isFavorite | boolean | Yes | Whether to favorite or unfavorite the file. The value **true** means to favorite the file, and **false** means to unfavorite the file.|
| isFavorite | boolean | Yes | Operation to perform. The value **true** means to favorite the file asset, and **false** means the opposite.|
**Return value**
| Type | Description |
| ------------------- | ---------- |
| Promise<void> | Void promise.|
| Promise<void> | Promise that returns no value.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the file asset is favorited.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the file asset is favorited; the value **false** means the opposite.|
@@ -1657,27 +1672,27 @@ Checks whether this file asset is favorited. This API uses a promise to return t
| Type | Description |
| ---------------------- | ------------------ |
| Promise<boolean> | Promise used to return whether the file asset is favorited.|
| Promise<boolean> | Promise used to return the result. The value **true** means the file asset is favorited; the value **false** means the opposite.|
| isTrash | boolean | Yes | Whether to move the file asset to the trash. The value **true** means to move the file asset to the trash, and **false** means the opposite.|
console.error('mediaLibrary trash failed with error: '+error);
}else{
console.info('mediaLibrary trash Successful');
}
});
fetchFileResult.close();
}
```
...
...
@@ -1740,33 +1755,33 @@ Files in the trash are not actually deleted. You can set **isTrash** to **false*
| Name | Type | Mandatory | Description |
| ------- | ------- | ---- | --------- |
| isTrash | boolean | Yes | Whether to move the file asset to the trash. The value **true** means to move the file asset to the trash, and **false** means the opposite.|
| isTrash | boolean | Yes | Whether to move the file asset to the trash.|
**Return value**
| Type | Description |
| ------------------- | ---------- |
| Promise<void> | Void promise.|
| Promise<void> | Promise that returns no value.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the file asset is in the trash. If the file asset is in the trash, **true** will be returned; otherwise, **false** will be returned.|
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. The value **true** means the file is in the trash; the value **false** means the opposite.|
console.error('Failed to get trash state failed with error: '+error);
return;
}
console.info('Get trash state successfully, isTrash result: '+isTrash);
});
fetchFileResult.close();
}
```
...
...
@@ -1824,33 +1839,33 @@ Checks whether this file asset is in the trash. This API uses a promise to retur
| Type | Description |
| ------------------- | -------------------- |
| Promise<void> | Promise used to return whether the file asset is in the trash. If the file asset is in the trash, **true** will be returned; otherwise, **false** will be returned.|
| Promise<void> | Promise used to return the result. The value **true** means the file is in the trash; the value **false** means the opposite.|
Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to ensure that the cursor does not point to the last file asset in the result set.
> **NOTE**<br>Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to ensure that the cursor does not point to the last file asset in the result set.
Obtains the next file asset in the result set. This API uses a promise to return the result.
> **NOTE**
>
> Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to ensure that the cursor does not point to the last file asset in the result set.
> **NOTE**<br>Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to ensure that the cursor does not point to the last file asset in the result set.
| index | number | Yes | Index of the file to obtain. The value starts from 0 and must be smaller than the **count** value of the result set. |
| callback | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Callback used to return the last file asset.|
| callback | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Callback invoked to return the **FileAsset** object with the specified index obtained.|
| callback | AsyncCallback<Array<[FileAsset](#fileasset7)>> | Yes | Callback used to return the file assets.|
| callback | AsyncCallback<Array<[FileAsset](#fileasset7)>> | Yes | Callback invoked to return all the **FileAsset** objects in the result reset.|
| selections | string | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' + mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
| selectionArgs | Array<string> | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.<br>Example:<br>selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], |
| selections | string | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names when files are fetched. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' + mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
| selectionArgs | Array<string> | Yes | Yes | Values of the conditions specified in **selections**.<br>Example:<br>selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], |
| order | string | Yes | Yes | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + ' ASC'<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + ' DESC'|
| src | string | Yes | Yes | Application sandbox oath of the local file. |
| mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.|
| relativePath | string | Yes | Yes | Custom path for storing media assets, for example, 'Pictures/'. If this parameter is unspecified, media assets are stored in the default path.<br> Default path of images: 'Pictures/'<br> Default path of videos: 'Videos/'<br> Default path of audios: 'Audios/'<br> Default path of files: 'Documents/'|
| relativePath | string | Yes | Yes | Custom path of media assets, for example, **Pictures/**. If this parameter is unspecified, media assets are stored in the default path.<br> Default path of images: **'Pictures/'**<br> Default path of videos: **'Videos/'**<br> Default path of audios: **'Audios/'**<br> Default path of documents: **'Documents/'**|
Creates a dialog box for deleting photos. This API uses an asynchronous callback to return the result. The deleted photos are moved to the recycle bin.
Creates a dialog box for deleting photos. This API uses an asynchronous callback to return the result. The deleted photos are moved to the trash.
Recovers image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses an asynchronous callback to return the result.
Recovers image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses an asynchronous callback to return the result.
Recovers image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses a promise to return the result.
Recovers image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses a promise to return the result.
Deletes image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses an asynchronous callback to return the result.
Deletes image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses an asynchronous callback to return the result.
**CAUTION**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation.
Deletes image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses a promise to return the result.
Deletes image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses a promise to return the result.
**CAUTION**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation.
...
...
@@ -3568,7 +3568,7 @@ Enumerate the album subtypes.
| FAVORITE | 1025 | Favorites.|
| VIDEO | 1026 | Video album.|
| HIDDEN | 1027 | Hidden album. **System API**: This is a system API.|
| TRASH | 1028 | Recycle bin. **System API**: This is a system API.|
| TRASH | 1028 | Trash. **System API**: This is a system API.|
| SCREENSHOT | 1029 | Album for screenshots and screen recording files. **System API**: This is a system API.|
| CAMERA | 1030 | Album for photos and videos taken by the camera. **System API**: This is a system API.|
From API version 10, the albums represented by physical directories are replaced by logical albums, which allows multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. See the following example:
1. Use [getMediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md#medialibrarygetmedialibrary) to obtain a **MediaLibrary** instance.
2. Use [MediaFetchOptions](../../../application-dev/reference/apis/js-apis-medialibrary.md#mediafetchoptions7) to create the file fetching options.
3. Use [getFileAssets](../../../application-dev/reference/apis/js-apis-medialibrary.md#getfileassets7) to obtain file assets.
From the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed as an album.
**getAlbums**
From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**, and the values of **ALBUM_NAME** can be **Camera** and **Screenshots** only. See the following example:
1. Use [getMediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md#medialibrarygetmedialibrary) to obtain a **MediaLibrary** instance.
2. Use [MediaFetchOptions](../../../application-dev/reference/apis/js-apis-medialibrary.md#mediafetchoptions7) to create the album fetching options.
3. Use [getAlbums](../../../application-dev/reference/apis/js-apis-medialibrary.md#getalbums7) to obtain albums.
console.info('mediaLibrary album albumName: '+albumList[i].albumName);
}
}catch(err){
console.error('mediaLibrary fail, err: '+err);
}
}
```
**FileAsset.commitModify**
The **orientation** attribute for audio is deleted from the SDK of API version 10. When **commitModify** is used, the **orientation** attribute of audio resources cannot be modified.