From 96ba3d57f526c39bd840c62be12104e885fd51f8 Mon Sep 17 00:00:00 2001 From: wusongqing Date: Tue, 29 Mar 2022 20:45:47 +0800 Subject: [PATCH] updated medialibrary api Signed-off-by: wusongqing --- .../reference/apis/js-apis-medialibrary.md | 442 +++++++++--------- 1 file changed, 232 insertions(+), 210 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-medialibrary.md b/en/application-dev/reference/apis/js-apis-medialibrary.md index b741802e7e..ceb96f2481 100644 --- a/en/application-dev/reference/apis/js-apis-medialibrary.md +++ b/en/application-dev/reference/apis/js-apis-medialibrary.md @@ -8,19 +8,19 @@ import mediaLibrary from '@ohos.multimedia.medialibrary'; ``` -## mediaLibrary.getMediaLibrary +## mediaLibrary.getMediaLibrary8+ getMediaLibrary(context: Context): MediaLibrary -Obtains a **MediaLibrary** instance, which is used to access and modify personal data of users. +Obtains a **MediaLibrary** instance, which is used to access and modify personal media data such as audios, videos, images, and documents. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ------- | ---- | ---------------------------------------- | -| context | Context | Yes | Context of the ability. This parameter is optional for API version 7 and earlier versions, but mandatory for API version 8 and later versions.| +| Name | Type | Mandatory| Description | +| ------- | ------- | ---- | -------------------------- | +| context | Context | Yes | Context of the ability.| **Return value** @@ -36,9 +36,31 @@ import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext() var media = mediaLibrary.getMediaLibrary(context); ``` +## mediaLibrary.getMediaLibrary + +getMediaLibrary(): MediaLibrary + +Obtains a **MediaLibrary** instance, which is used to access and modify personal media data such as audios, videos, images, and documents. + +> **Note**: This API is no longer maintained since API version 8. You are advised to use [mediaLibrary.getMediaLibrary8+](#medialibrarygetmedialibrary8) instead. + +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core + +**Return value** + +| Type | Description | +| ----------------------------- | :--------- | +| [MediaLibrary](#medialibrary) | **MediaLibrary** instance.| + +**Example** + +```js +var media = mediaLibrary.getMediaLibrary(); +``` + ## MediaLibrary -### getFileAssets8+ +### getFileAssets7+ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileResult>): void @@ -51,10 +73,10 @@ Obtains file assets (also called files). This API uses an asynchronous callback **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ------------------------ | -| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files. | -| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | Yes | Asynchronous callback of **FetchFileResult**.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | --------------------------------- | +| options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the files. | +| callback | AsyncCallback<[FetchFileResult](#fetchfileresult7)> | Yes | Asynchronous callback of **FetchFileResult**.| **Example** @@ -76,7 +98,7 @@ mediaLibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { } }); ``` -### getFileAssets8+ +### getFileAssets7+ getFileAssets(options: MediaFetchOptions): Promise<FetchFileResult> @@ -88,15 +110,15 @@ Obtains file assets. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ---------------------------------------- | ---- | ------ | -| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files.| +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------------- | ---- | ------------ | +| options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the files.| **Return value** -| Type | Description | -| ------------------------------------ | ------- | -| [FetchFileResult](#fetchfileresult8) | Result set of the file retrieval operation.| +| Type | Description | +| ------------------------------------ | -------------- | +| [FetchFileResult](#fetchfileresult7) | Result set of the file retrieval operation.| **Example** @@ -171,12 +193,12 @@ Creates a media asset. This API uses an asynchronous callback to return the resu **Parameters** -| Name | Type | Mandatory | Description | -| ------------ | --------------------------------------- | ---- | ---------------------------------------- | -| mediaType | [MediaType](#mediatype) | Yes | Media type. | -| displayName | string | Yes | Display file name. | -| relativePath | string | Yes | Path for storing the file. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the paths for storing different types of files.| -| callback | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Asynchronous callback for **FileAsset**. | +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------------- | ---- | ------------------------------------------------------------ | +| mediaType | [MediaType](#mediatype8) | Yes | Media type. | +| displayName | string | Yes | Display file name. | +| relativePath | string | Yes | Path for storing the file. You can use [getPublicDirectory](#getpublicdirectory8) to obtain the paths for storing different types of files.| +| callback | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Asynchronous callback for **FileAsset**. | **Example** @@ -208,17 +230,17 @@ Creates a media asset. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------------ | ----------------------- | ---- | ---------------------------------------- | -| mediaType | [MediaType](#mediatype) | Yes | Media type. | -| displayName | string | Yes | Display file name. | -| 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.| +| Name | Type | Mandatory| Description | +| ------------ | ------------------------ | ---- | ------------------------------------------------------------ | +| mediaType | [MediaType](#mediatype8) | Yes | Media type. | +| displayName | string | Yes | Display file name. | +| 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.| **Return value** -| Type | Description | -| ------------------------ | ------------- | -| [FileAsset](#fileasset8) | Media data (FileAsset).| +| Type | Description | +| ------------------------ | ----------------- | +| [FileAsset](#fileasset7) | Media data (FileAsset).| **Example** @@ -246,10 +268,10 @@ Obtains a public directory. This API uses an asynchronous callback to return the **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------- | ---- | ----------------- | -| type | [DirectoryType](#directorytype) | Yes | Type of the public directory. | -| callback | AsyncCallback<string> | Yes | Callback used to return the public directory.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------- | ---- | ------------------------- | +| type | [DirectoryType](#directorytype8) | Yes | Type of the public directory. | +| callback | AsyncCallback<string> | Yes | Callback used to return the public directory.| **Example** @@ -274,15 +296,15 @@ Obtains a public directory. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------------------------------- | ---- | ------ | -| type | [DirectoryType](#directorytype) | Yes | Type of the public directory.| +| Name| Type | Mandatory| Description | +| ------ | -------------------------------- | ---- | ------------ | +| type | [DirectoryType](#directorytype8) | Yes | Type of the public directory.| **Return value** -| Type | Description | -| --------------- | -------- | -| Promise | Promise used to return the public directory.| +| Type | Description | +| ---------------- | ---------------- | +| Promise\ | Promise used to return the public directory.| **Example** @@ -298,7 +320,7 @@ async function example() { } ``` -### getAlbums8+ +### getAlbums7+ getAlbums(options: MediaFetchOptions, callback: AsyncCallback): void @@ -310,10 +332,10 @@ Obtains the albums. This API uses an asynchronous callback to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ---------------- | -| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the albums. | -| callback | AsyncCallback<Array<[Album](#album8)>> | Yes | Callback used to return the albums.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------- | ---- | --------------------------- | +| options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the albums. | +| callback | AsyncCallback<Array<[Album](#album7)>> | Yes | Callback used to return the albums.| **Example** @@ -333,7 +355,7 @@ mediaLibrary.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => { }) ``` -### getAlbums8+ +### getAlbums7+ getAlbums(options: MediaFetchOptions): Promise @@ -345,15 +367,15 @@ Obtains the albums. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ---------------------------------------- | ---- | ------ | -| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the albums.| +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------------- | ---- | ------------ | +| options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the albums.| **Return value** -| Type | Description | -| -------------------------------- | --------- | -| Promise> | Promise used to return the albums.| +| Type | Description | +| -------------------------------- | ------------- | +| Promise> | Promise used to return the albums.| **Example** @@ -690,7 +712,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => { ``` -## FileAsset8+ +## FileAsset7+ Provides APIs for encapsulating file asset attributes. @@ -698,29 +720,29 @@ Provides APIs for encapsulating file asset attributes. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Type | Readable | Writable | Description | -| ------------ | ----------------------- | ---- | ---- | --------------------------------------- | -| id | number | Yes | No | File asset ID. | -| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2.| -| mimeType | string | Yes | No | Extended file attributes. | -| mediaType | [MediaType](#mediatype) | Yes | No | Media type. | -| displayName | string | Yes | Yes | Display file name, including the file name extension. | -| title | string | Yes | Yes | Title in the file. | -| relativePath | string | Yes | Yes | Relative public directory of the file. | -| parent | number | Yes | No | Parent directory ID. | -| 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 was modified. (The value is the number of seconds elapsed since the Epoch time.) | -| dateTaken | number | Yes | No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | -| artist | string | Yes | No | Artist of the file. | -| audioAlbum | string | Yes | No | Audio album. | -| width | number | Yes | No | Image width, in pixels. | -| 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 | number | Yes | No | Duration, in seconds. | -| albumId | number | Yes | No | ID of the album to which the file belongs. | -| albumUri | 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. | +| Name | Type | Readable| Writable| Description | +| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ | +| id | number | Yes | No | File asset ID. | +| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. | +| mimeType | string | Yes | No | Extended file attributes. | +| mediaType8+ | [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. | +| relativePath8+ | string | Yes | Yes | Relative public directory of the file. | +| parent8+ | number | Yes | No | Parent directory ID. | +| 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 was modified. (The value is the number of seconds elapsed since the Epoch time.) | +| dateTaken | number | Yes | No | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | +| artist8+ | string | Yes | No | Artist of the file. | +| audioAlbum8+ | string | Yes | No | Audio album. | +| width | number | Yes | No | Image width, in pixels. | +| 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).| +| duration8+ | number | Yes | No | Duration, in seconds. | +| albumId | number | Yes | No | ID of the album to which the file belongs. | +| albumUri8+ | 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. | ### isDirectory8+ @@ -1127,15 +1149,19 @@ Obtains the thumbnail of this file asset, with the thumbnail size passed. This A async function example() { let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [imageType.toString()], - order: fileKeyObj.DATE_ADDED + " DESC", - extendArgs: "", + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); - asset.getThumbnail(size, (err, pixelmap) => { + asset.getThumbnail(size) + .then((pixelmap) => { console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); + }) + .catch((err) => { + console.info('mediaLibraryTest : getThumbnail fail'+ err); }); } ``` @@ -1460,11 +1486,11 @@ async function example() { } ``` -## FetchFileResult8+ +## FetchFileResult7+ Implements the result set of the file retrieval operation. -### getCount8+ +### getCount7+ getCount(): number @@ -1493,7 +1519,7 @@ async function example() { } ``` -### isAfterLast8+ +### isAfterLast7+ isAfterLast(): boolean @@ -1536,7 +1562,7 @@ async function example() { } ``` -### close8+ +### close7+ close(): void @@ -1560,7 +1586,7 @@ async function example() { } ``` -### getFirstObject8+ +### getFirstObject7+ getFirstObject(callback: AsyncCallback<FileAsset>): void @@ -1570,9 +1596,9 @@ Obtains the first file asset in the result set. This API uses an asynchronous ca **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | -------------------------- | -| callback | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Callback used to return the first file asset.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------- | ---- | ------------------------------------------- | +| callback | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Callback used to return the first file asset.| **Example** @@ -1596,7 +1622,7 @@ async function example() { } ``` -### getFirstObject8+ +### getFirstObject7+ getFirstObject(): Promise<FileAsset> @@ -1606,9 +1632,9 @@ Obtains the first file asset in the result set. This API uses a promise to retur **Return value** -| Type | Description | -| --------------------------------------- | -------------------- | -| Promise<[FileAsset](#fileasset8)> | Promise used to return the file asset.| +| Type | Description | +| --------------------------------------- | -------------------------- | +| Promise<[FileAsset](#fileasset7)> | Promise used to return the file asset.| **Example** @@ -1630,7 +1656,7 @@ async function example() { } ``` -### getNextObject8+ +### getNextObject7+ getNextObject(callback: AsyncCallback<FileAsset>): void @@ -1642,9 +1668,9 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ---------------------------------------- | ---- | ------------------------- | -| callbacke | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Callback used to return the next file asset.| +| Name | Type | Mandatory| Description | +| --------- | --------------------------------------------- | ---- | ----------------------------------------- | +| callbacke | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Callback used to return the next file asset.| **Example** @@ -1668,7 +1694,7 @@ async function example() { } ``` -### getNextObject8+ +### getNextObject7+ getNextObject(): Promise<FileAsset> @@ -1680,9 +1706,9 @@ Obtains the next file asset in the result set. This API uses a promise to return **Return value** -| Type | Description | -| --------------------------------------- | ------------- | -| Promise<[FileAsset](#fileasset8)> | Promise used to return the next file asset.| +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<[FileAsset](#fileasset7)> | Promise used to return the next file asset.| **Example** @@ -1702,7 +1728,7 @@ async function example() { } ``` -### getLastObject8+ +### getLastObject7+ getLastObject(callback: AsyncCallback<FileAsset>): void @@ -1712,9 +1738,9 @@ Obtains the last file asset in the result set. This API uses an asynchronous cal **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ------------------ | -| callback | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Callback used to return the last file asset.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------- | ---- | --------------------------- | +| callback | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Callback used to return the last file asset.| **Example** @@ -1738,7 +1764,7 @@ async function example() { } ``` -### getLastObject8+ +### getLastObject7+ getLastObject(): Promise<FileAsset> @@ -1748,9 +1774,9 @@ Obtains the last file asset in the result set. This API uses a promise to return **Return value** -| Type | Description | -| --------------------------------------- | ------------- | -| Promise<[FileAsset](#fileasset8)> | Promise used to return the next file asset.| +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<[FileAsset](#fileasset7)> | Promise used to return the next file asset.| **Example** @@ -1768,7 +1794,7 @@ async function example() { } ``` -### getPositionObject8+ +### getPositionObject7+ getPositionObject(index: number, callback: AsyncCallback<FileAsset>): void @@ -1781,7 +1807,7 @@ Obtains a file asset with the specified index in the result set. This API uses a | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------ | | index | number | Yes | Index of the file asset to obtain. The value starts from **0**. | -| callback | AsyncCallback<[FileAsset](#fileasset8)> | Yes | Callback used to return the last file asset.| +| callback | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Callback used to return the last file asset.| **Example** @@ -1805,7 +1831,7 @@ async function example() { } ``` -### getPositionObject8+ +### getPositionObject7+ getPositionObject(index: number): Promise<FileAsset> @@ -1823,9 +1849,9 @@ Obtains a file asset with the specified index in the result set. This API uses a **Return value** -| Type | Description | -| --------------------------------------- | ------------- | -| Promise<[FileAsset](#fileasset8)> | Promise used to return the next file asset.| +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<[FileAsset](#fileasset7)> | Promise used to return the next file asset.| **Example** @@ -1849,7 +1875,7 @@ async function example() { } ``` -### getAllObject8+ +### getAllObject7+ getAllObject(callback: AsyncCallback<Array<FileAsset>>): void @@ -1863,7 +1889,7 @@ Obtains all the file assets in the result set. This API uses an asynchronous cal | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | -------------------- | -| callback | AsyncCallback> | Yes | Callback used to return the file assets.| +| callback | AsyncCallback> | Yes | Callback used to return the file assets.| **Example** @@ -1887,7 +1913,7 @@ async function example() { } ``` -### getAllObject8+ +### getAllObject7+ getAllObject(): Promise<Array<FileAsset>> @@ -1897,9 +1923,9 @@ Obtains all the file assets in the result set. This API uses a promise to return **Return value** -| Type | Description | -| ---------------------------------------- | --------------- | -| Promise> | Promise used to return the file assets.| +| Type | Description | +| ---------------------------------------- | --------------------- | +| Promise> | Promise used to return the file assets.| **Example** @@ -1917,7 +1943,7 @@ async function example() { } ``` -## Album8+ +## Album7+ Provides APIs to implement a physical album. @@ -1927,13 +1953,13 @@ Provides APIs to implement a physical album. | Name | Type | Readable | Writable | Description | | ------------ | ------ | ---- | ---- | ------- | -| albumId | number | Yes | No | Album ID. | -| albumName | string | Yes | Yes | Album name. | -| albumUri | string | Yes | No | Album URI. | +| albumId | number | Yes | No | Album ID. | +| albumName | string | Yes | Yes | Album name. | +| albumUri8+ | string | Yes | No | Album URI. | | dateModified | number | Yes | No | Date when the album was modified. | -| count | number | Yes | No | Number of files in the album.| -| relativePath | string | Yes | No | Relative path of the album. | -| coverUri | string | Yes | No | URI of the cover file of the album.| +| count8+ | number | Yes | No | Number of files in the album.| +| relativePath8+ | string | Yes | No | Relative path of the album. | +| coverUri8+ | string | Yes | No | URI of the cover file of the album.| ### commitModify8+ @@ -1947,9 +1973,9 @@ Commits the modification of the album attributes to the database. This API uses **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------- | ---- | ----- | -| callback | AsyncCallback<void> | Yes | Void callback.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | Yes | Void callback.| **Example** @@ -2007,7 +2033,7 @@ async function example() { } ``` -### getFileAssets8+ +### getFileAssets7+ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileResult>): void @@ -2019,10 +2045,10 @@ Obtains the file assets in this album. This API uses an asynchronous callback to **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ------------------------ | -| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files. | -| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | Yes | Callback used to return the file assets.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | ----------------------------------- | +| options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the files. | +| callback | AsyncCallback<[FetchFileResult](#fetchfileresult7)> | Yes | Callback used to return the file assets.| **Example** @@ -2041,7 +2067,7 @@ async function example() { } ``` -### getFileAssets8+ +### getFileAssets7+ getFileAssets(options?: MediaFetchOptions): Promise<FetchFileResult> @@ -2053,15 +2079,15 @@ Obtains the file assets in this album. This API uses a promise to return the res **Parameters** -| Name | Type | Mandatory | Description | -| ------- | ---------------------------------------- | ---- | ------ | -| options | [MediaFetchOptions](#mediafetchoptions8) | No | Options for fetching the files.| +| Name | Type | Mandatory| Description | +| ------- | ---------------------------------------- | ---- | -------------- | +| options | [MediaFetchOptions](#mediafetchoptions7) | No | Options for fetching the files.| **Return value** -| Type | Description | -| ---------------------------------------- | ------------------- | -| Promise<[FetchFileResult](#fetchfileresult8)> | Promise used to return the file assets.| +| Type | Description | +| --------------------------------------------- | ------------------------- | +| Promise<[FetchFileResult](#fetchfileresult7)> | Promise used to return the file assets.| **Example** @@ -2087,105 +2113,101 @@ Describes information about a registered device. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Type | Readable | Writable | Description | -| ---------- | ---------- | ---- | ---- | --------- | -| deviceName | string | Yes | No | Name of the registered device. | -| networkId | string | Yes | No | Network ID of the registered device.| -| deviceType | DeviceType | Yes | No | Type of the registered device. | -| isOnline | boolean | Yes | No | Whether the registered device is online. | +| Name | Type | Readable| Writable| Description | +| ---------- | -------------------------- | ---- | ---- | ---------------- | +| deviceName | string | Yes | No | Name of the registered device. | +| networkId | string | Yes | No | Network ID of the registered device.| +| deviceType | [DeviceType](#devicetype8) | Yes | No | Type of the registered device. | +| isOnline | boolean | Yes | No | Whether the registered device is online. | -MediaType ---------- +## MediaType8+ Enumerates media types. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Default Value | Description | -| ----- | ---- | ---- | -| FILE | 0 | File. | -| IMAGE | 1 | Image. | -| VIDEO | 2 | Video. | -| AUDIO | 3 | Audio. | +| Name | Default Value | Description| +| ----- | ------ | ---- | +| FILE | 1 | File.| +| IMAGE | 3 | Image.| +| VIDEO | 4 | Video.| +| AUDIO | 5 | Audio.| -FileKey -------- +## FileKey8+ Enumerates key file information. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Default Value | Description | -| ------------- | ------------------- | -------------------------------- | -| ID | file_id | File ID. | -| RELATIVE_PATH | relative_path | Relative public directory of the file. | -| DISPLAY_NAME | display_name | Display file name. | -| PARENT | parent | Parent directory ID. | -| MIME_TYPE | mime_type | Extended file attributes. | -| MEDIA_TYPE | media_type | Media type. | -| SIZE | size | File size, in bytes. | -| DATE_ADDED | date_added | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) | -| DATE_MODIFIED | date_modified | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) | -| DATE_TAKEN | date_taken | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | -| TITLE | title | Title in the file. | -| ARTIST | artist | Artist of the file. | -| AUDIOALBUM | audio_album | Audio album. | -| DURATION | duration | Duration, in seconds. | -| WIDTH | width | Image width, in pixels. | -| HEIGHT | height | Image height, in pixels. | +| Name | Default Value | Description | +| ------------- | ------------------- | ---------------------------------------------------------- | +| ID | file_id | File ID. | +| RELATIVE_PATH | relative_path | Relative public directory of the file. | +| DISPLAY_NAME | display_name | Display file name. | +| PARENT | parent | Parent directory ID. | +| MIME_TYPE | mime_type | Extended file attributes. | +| MEDIA_TYPE | media_type | Media type. | +| SIZE | size | File size, in bytes. | +| DATE_ADDED | date_added | Date when the file was added. (The value is the number of seconds elapsed since the Epoch time.) | +| DATE_MODIFIED | date_modified | Date when the file was modified. (The value is the number of seconds elapsed since the Epoch time.) | +| DATE_TAKEN | date_taken | Date when the file (photo) was taken. (The value is the number of seconds elapsed since the Epoch time.) | +| TITLE | title | Title in the file. | +| ARTIST | artist | Artist of the file. | +| AUDIOALBUM | audio_album | Audio album. | +| DURATION | duration | Duration, in seconds. | +| WIDTH | width | Image width, in pixels. | +| HEIGHT | height | Image height, in pixels. | | ORIENTATION | orientation | Image display direction (clockwise rotation angle, for example, 0, 90, and 180, in degrees).| -| ALBUM_ID | bucket_id | ID of the album to which the file belongs. | -| ALBUM_NAME | bucket_display_name | Name of the album to which the file belongs. | +| ALBUM_ID | bucket_id | ID of the album to which the file belongs. | +| ALBUM_NAME | bucket_display_name | Name of the album to which the file belongs. | -DirectoryType -------------- +## DirectoryType8+ Enumerates directory types. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Default Value | Description | -| ------------- | ---- | ------------ | -| DIR_CAMERA | 0 | Directory of camera files.| -| DIR_VIDEO | 1 | Directory of video files. | -| DIR_IMAGE | 2 | Directory of image files. | -| DIR_AUDIO | 3 | Directory of audio files. | -| DIR_DOCUMENTS | 4 | Directory of documents. | -| DIR_DOWNLOAD | 5 | Download directory. | +| Name | Default Value | Description | +| ------------- | ------ | ------------------ | +| DIR_CAMERA | 0 | Directory of camera files.| +| DIR_VIDEO | 1 | Directory of video files. | +| DIR_IMAGE | 2 | Directory of image files. | +| DIR_AUDIO | 3 | Directory of audio files. | +| DIR_DOCUMENTS | 4 | Directory of documents. | +| DIR_DOWNLOAD | 5 | Download directory. | -DeviceType ------------ +## DeviceType8+ Enumerates device types. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Default Value | Description | -| ------------ | ---- | ----- | -| TYPE_UNKNOWN | 0 | Unknown.| -| TYPE_LAPTOP | 1 | Laptop.| -| TYPE_PHONE | 2 | Phone. | -| TYPE_TABLET | 3 | Tablet. | -| TYPE_WATCH | 4 | Smart watch. | -| TYPE_CAR | 5 | Vehicle-mounted device. | -| TYPE_TV | 6 | TV. | +| Name | Default Value | Description | +| ------------ | ------ | ---------- | +| TYPE_UNKNOWN | 0 | Unknown.| +| TYPE_LAPTOP | 1 | Laptop.| +| TYPE_PHONE | 2 | Phone. | +| TYPE_TABLET | 3 | Tablet. | +| TYPE_WATCH | 4 | Smart watch. | +| TYPE_CAR | 5 | Vehicle-mounted device. | +| TYPE_TV | 6 | TV. | -## MediaFetchOptions8+ +## MediaFetchOptions7+ Describes options for fetching media files. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Type | Readable | Writable | Mandatory | Description | -| ------------- | ------------------- | ---- | ---- | ---- | ---------------------------------------- | -| selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey) are used as the column names of the conditions. Example:
selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?',| -| selectionArgs | Array<string> | Yes | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.
Example:
selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], | -| order | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey) are used as the columns for sorting the search results. Example:
Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"
Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"| -| uri | string | Yes | Yes | No | File URI. | -| networkId | string | Yes | Yes | No | Network ID of the registered device. | -| extendArgs | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. | +| Name | Type | Readable| Writable| Mandatory| Description | +| ----------------------- | ------------------- | ---- | ---- | ---- | ------------------------------------------------------------ | +| selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:
selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?',| +| selectionArgs | Array<string> | Yes | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.
Example:
selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], | +| order8+ | string | Yes | Yes | No | 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:
Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"
Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"| +| uri8+ | string | Yes | Yes | No | File URI. | +| networkId8+ | string | Yes | Yes | No | Network ID of the registered device. | +| extendArgs8+ | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. | ## Size8+ -- GitLab