提交 96ba3d57 编写于 作者: W wusongqing

updated medialibrary api

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 ec434260
...@@ -8,19 +8,19 @@ ...@@ -8,19 +8,19 @@
import mediaLibrary from '@ohos.multimedia.medialibrary'; import mediaLibrary from '@ohos.multimedia.medialibrary';
``` ```
## mediaLibrary.getMediaLibrary ## mediaLibrary.getMediaLibrary<sup>8+</sup>
getMediaLibrary(context: Context): MediaLibrary 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 **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | 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.| | context | Context | Yes | Context of the ability.|
**Return value** **Return value**
...@@ -36,9 +36,31 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -36,9 +36,31 @@ import featureAbility from '@ohos.ability.featureAbility';
var context = featureAbility.getContext() var context = featureAbility.getContext()
var media = mediaLibrary.getMediaLibrary(context); 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.getMediaLibrary<sup>8+</sup>](#medialibrarygetmedialibrary8) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
**Return value**
| Type | Description |
| ----------------------------- | :--------- |
| [MediaLibrary](#medialibrary) | **MediaLibrary** instance.|
**Example**
```js
var media = mediaLibrary.getMediaLibrary();
```
## MediaLibrary ## MediaLibrary
### getFileAssets<sup>8+</sup> ### getFileAssets<sup>7+</sup>
getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void
...@@ -51,10 +73,10 @@ Obtains file assets (also called files). This API uses an asynchronous callback ...@@ -51,10 +73,10 @@ Obtains file assets (also called files). This API uses an asynchronous callback
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ | | -------- | --------------------------------------------------- | ---- | --------------------------------- |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files. | | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the files. |
| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | Yes | Asynchronous callback of **FetchFileResult**.| | callback | AsyncCallback<[FetchFileResult](#fetchfileresult7)> | Yes | Asynchronous callback of **FetchFileResult**.|
**Example** **Example**
...@@ -76,7 +98,7 @@ mediaLibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { ...@@ -76,7 +98,7 @@ mediaLibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => {
} }
}); });
``` ```
### getFileAssets<sup>8+</sup> ### getFileAssets<sup>7+</sup>
getFileAssets(options: MediaFetchOptions): Promise&lt;FetchFileResult&gt; getFileAssets(options: MediaFetchOptions): Promise&lt;FetchFileResult&gt;
...@@ -88,15 +110,15 @@ Obtains file assets. This API uses a promise to return the result. ...@@ -88,15 +110,15 @@ Obtains file assets. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------------------------- | ---- | ------ | | ------- | ---------------------------------------- | ---- | ------------ |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files.| | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the files.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------ | ------- | | ------------------------------------ | -------------- |
| [FetchFileResult](#fetchfileresult8) | Result set of the file retrieval operation.| | [FetchFileResult](#fetchfileresult7) | Result set of the file retrieval operation.|
**Example** **Example**
...@@ -171,12 +193,12 @@ Creates a media asset. This API uses an asynchronous callback to return the resu ...@@ -171,12 +193,12 @@ Creates a media asset. This API uses an asynchronous callback to return the resu
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------------ | --------------------------------------- | ---- | ---------------------------------------- | | ------------ | --------------------------------------- | ---- | ------------------------------------------------------------ |
| mediaType | [MediaType](#mediatype) | Yes | Media type. | | mediaType | [MediaType](#mediatype8) | Yes | Media type. |
| displayName | string | Yes | Display file name. | | 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.| | 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**. | | callback | AsyncCallback<[FileAsset](#fileasset7)> | Yes | Asynchronous callback for **FileAsset**. |
**Example** **Example**
...@@ -208,17 +230,17 @@ Creates a media asset. This API uses a promise to return the result. ...@@ -208,17 +230,17 @@ Creates a media asset. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------------ | ----------------------- | ---- | ---------------------------------------- | | ------------ | ------------------------ | ---- | ------------------------------------------------------------ |
| mediaType | [MediaType](#mediatype) | Yes | Media type. | | mediaType | [MediaType](#mediatype8) | Yes | Media type. |
| displayName | string | Yes | Display file name. | | 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.| | 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** **Return value**
| Type | Description | | Type | Description |
| ------------------------ | ------------- | | ------------------------ | ----------------- |
| [FileAsset](#fileasset8) | Media data (FileAsset).| | [FileAsset](#fileasset7) | Media data (FileAsset).|
**Example** **Example**
...@@ -246,9 +268,9 @@ Obtains a public directory. This API uses an asynchronous callback to return the ...@@ -246,9 +268,9 @@ Obtains a public directory. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ----------------- | | -------- | -------------------------------- | ---- | ------------------------- |
| type | [DirectoryType](#directorytype) | Yes | Type of the public directory. | | type | [DirectoryType](#directorytype8) | Yes | Type of the public directory. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the public directory.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the public directory.|
**Example** **Example**
...@@ -274,15 +296,15 @@ Obtains a public directory. This API uses a promise to return the result. ...@@ -274,15 +296,15 @@ Obtains a public directory. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type | Mandatory| Description |
| ---- | ------------------------------- | ---- | ------ | | ------ | -------------------------------- | ---- | ------------ |
| type | [DirectoryType](#directorytype) | Yes | Type of the public directory.| | type | [DirectoryType](#directorytype8) | Yes | Type of the public directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | -------- | | ---------------- | ---------------- |
| Promise<string> | Promise used to return the public directory.| | Promise\<string> | Promise used to return the public directory.|
**Example** **Example**
...@@ -298,7 +320,7 @@ async function example() { ...@@ -298,7 +320,7 @@ async function example() {
} }
``` ```
### getAlbums<sup>8+</sup> ### getAlbums<sup>7+</sup>
getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array&lt;Album&gt;>): void getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array&lt;Album&gt;>): void
...@@ -310,10 +332,10 @@ Obtains the albums. This API uses an asynchronous callback to return the result. ...@@ -310,10 +332,10 @@ Obtains the albums. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ---------------- | | -------- | -------------------------------------------- | ---- | --------------------------- |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the albums. | | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the albums. |
| callback | AsyncCallback&lt;Array<[Album](#album8)>&gt; | Yes | Callback used to return the albums.| | callback | AsyncCallback&lt;Array<[Album](#album7)>&gt; | Yes | Callback used to return the albums.|
**Example** **Example**
...@@ -333,7 +355,7 @@ mediaLibrary.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => { ...@@ -333,7 +355,7 @@ mediaLibrary.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => {
}) })
``` ```
### getAlbums<sup>8+</sup> ### getAlbums<sup>7+</sup>
getAlbums(options: MediaFetchOptions): Promise<Array&lt;Album&gt;> getAlbums(options: MediaFetchOptions): Promise<Array&lt;Album&gt;>
...@@ -345,15 +367,15 @@ Obtains the albums. This API uses a promise to return the result. ...@@ -345,15 +367,15 @@ Obtains the albums. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------------------------- | ---- | ------ | | ------- | ---------------------------------------- | ---- | ------------ |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the albums.| | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the albums.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | --------- | | -------------------------------- | ------------- |
| Promise<Array<[Album](#album8)>> | Promise used to return the albums.| | Promise<Array<[Album](#album7)>> | Promise used to return the albums.|
**Example** **Example**
...@@ -690,7 +712,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => { ...@@ -690,7 +712,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => {
``` ```
## FileAsset<sup>8+</sup> ## FileAsset<sup>7+</sup>
Provides APIs for encapsulating file asset attributes. Provides APIs for encapsulating file asset attributes.
...@@ -698,28 +720,28 @@ Provides APIs for encapsulating file asset attributes. ...@@ -698,28 +720,28 @@ Provides APIs for encapsulating file asset attributes.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable | Writable | Description | | Name | Type | Readable| Writable| Description |
| ------------ | ----------------------- | ---- | ---- | --------------------------------------- | | ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
| id | number | Yes | No | File asset ID. | | id | number | Yes | No | File asset ID. |
| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2.| | uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. |
| mimeType | string | Yes | No | Extended file attributes. | | mimeType | string | Yes | No | Extended file attributes. |
| mediaType | [MediaType](#mediatype) | Yes | No | Media type. | | mediaType<sup>8+</sup> | [MediaType](#mediatype8) | Yes | No | Media type. |
| displayName | string | Yes | Yes | Display file name, including the file name extension. | | displayName | string | Yes | Yes | Display file name, including the file name extension. |
| title | string | Yes | Yes | Title in the file. | | title | string | Yes | Yes | Title in the file. |
| relativePath | string | Yes | Yes | Relative public directory of the file. | | relativePath<sup>8+</sup> | string | Yes | Yes | Relative public directory of the file. |
| parent | number | Yes | No | Parent directory ID. | | parent<sup>8+</sup> | number | Yes | No | Parent directory ID. |
| size | number | Yes | No | File size, in bytes. | | 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.) | | 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.) | | 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.) | | 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. | | artist<sup>8+</sup> | string | Yes | No | Artist of the file. |
| audioAlbum | string | Yes | No | Audio album. | | audioAlbum<sup>8+</sup> | string | Yes | No | Audio album. |
| width | number | Yes | No | Image width, in pixels. | | width | number | Yes | No | Image width, in pixels. |
| height | number | Yes | No | Image height, 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). | | 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. | | duration<sup>8+</sup> | number | Yes | No | Duration, in seconds. |
| albumId | number | Yes | No | ID of the album to which the file belongs. | | 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. | | 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. | | albumName | string | Yes | No | Name of the album to which the file belongs. |
...@@ -1134,8 +1156,12 @@ async function example() { ...@@ -1134,8 +1156,12 @@ async function example() {
}; };
const fetchFileResult = await media.getFileAssets(getImageOp); const fetchFileResult = await media.getFileAssets(getImageOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.getThumbnail(size, (err, pixelmap) => { asset.getThumbnail(size)
.then((pixelmap) => {
console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap);
})
.catch((err) => {
console.info('mediaLibraryTest : getThumbnail fail'+ err);
}); });
} }
``` ```
...@@ -1460,11 +1486,11 @@ async function example() { ...@@ -1460,11 +1486,11 @@ async function example() {
} }
``` ```
## FetchFileResult<sup>8+</sup> ## FetchFileResult<sup>7+</sup>
Implements the result set of the file retrieval operation. Implements the result set of the file retrieval operation.
### getCount<sup>8+</sup> ### getCount<sup>7+</sup>
getCount(): number getCount(): number
...@@ -1493,7 +1519,7 @@ async function example() { ...@@ -1493,7 +1519,7 @@ async function example() {
} }
``` ```
### isAfterLast<sup>8+</sup> ### isAfterLast<sup>7+</sup>
isAfterLast(): boolean isAfterLast(): boolean
...@@ -1536,7 +1562,7 @@ async function example() { ...@@ -1536,7 +1562,7 @@ async function example() {
} }
``` ```
### close<sup>8+</sup> ### close<sup>7+</sup>
close(): void close(): void
...@@ -1560,7 +1586,7 @@ async function example() { ...@@ -1560,7 +1586,7 @@ async function example() {
} }
``` ```
### getFirstObject<sup>8+</sup> ### getFirstObject<sup>7+</sup>
getFirstObject(callback: AsyncCallback&lt;FileAsset&gt;): void getFirstObject(callback: AsyncCallback&lt;FileAsset&gt;): void
...@@ -1570,9 +1596,9 @@ Obtains the first file asset in the result set. This API uses an asynchronous ca ...@@ -1570,9 +1596,9 @@ Obtains the first file asset in the result set. This API uses an asynchronous ca
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | -------------------------- | | -------- | --------------------------------------------- | ---- | ------------------------------------------- |
| callback | AsyncCallback&lt;[FileAsset](#fileasset8)&gt; | Yes | Callback used to return the first file asset.| | callback | AsyncCallback&lt;[FileAsset](#fileasset7)&gt; | Yes | Callback used to return the first file asset.|
**Example** **Example**
...@@ -1596,7 +1622,7 @@ async function example() { ...@@ -1596,7 +1622,7 @@ async function example() {
} }
``` ```
### getFirstObject<sup>8+</sup> ### getFirstObject<sup>7+</sup>
getFirstObject(): Promise&lt;FileAsset&gt; getFirstObject(): Promise&lt;FileAsset&gt;
...@@ -1607,8 +1633,8 @@ Obtains the first file asset in the result set. This API uses a promise to retur ...@@ -1607,8 +1633,8 @@ Obtains the first file asset in the result set. This API uses a promise to retur
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | -------------------- | | --------------------------------------- | -------------------------- |
| Promise&lt;[FileAsset](#fileasset8)&gt; | Promise used to return the file asset.| | Promise&lt;[FileAsset](#fileasset7)&gt; | Promise used to return the file asset.|
**Example** **Example**
...@@ -1630,7 +1656,7 @@ async function example() { ...@@ -1630,7 +1656,7 @@ async function example() {
} }
``` ```
### getNextObject<sup>8+</sup> ### getNextObject<sup>7+</sup>
getNextObject(callback: AsyncCallback&lt;FileAsset&gt;): void getNextObject(callback: AsyncCallback&lt;FileAsset&gt;): void
...@@ -1642,9 +1668,9 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal ...@@ -1642,9 +1668,9 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| --------- | ---------------------------------------- | ---- | ------------------------- | | --------- | --------------------------------------------- | ---- | ----------------------------------------- |
| callbacke | AsyncCallback&lt;[FileAsset](#fileasset8)&gt; | Yes | Callback used to return the next file asset.| | callbacke | AsyncCallback&lt;[FileAsset](#fileasset7)&gt; | Yes | Callback used to return the next file asset.|
**Example** **Example**
...@@ -1668,7 +1694,7 @@ async function example() { ...@@ -1668,7 +1694,7 @@ async function example() {
} }
``` ```
### getNextObject<sup>8+</sup> ### getNextObject<sup>7+</sup>
getNextObject(): Promise&lt;FileAsset&gt; getNextObject(): Promise&lt;FileAsset&gt;
...@@ -1681,8 +1707,8 @@ Obtains the next file asset in the result set. This API uses a promise to return ...@@ -1681,8 +1707,8 @@ Obtains the next file asset in the result set. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ------------- | | --------------------------------------- | ----------------- |
| Promise&lt;[FileAsset](#fileasset8)&gt; | Promise used to return the next file asset.| | Promise&lt;[FileAsset](#fileasset7)&gt; | Promise used to return the next file asset.|
**Example** **Example**
...@@ -1702,7 +1728,7 @@ async function example() { ...@@ -1702,7 +1728,7 @@ async function example() {
} }
``` ```
### getLastObject<sup>8+</sup> ### getLastObject<sup>7+</sup>
getLastObject(callback: AsyncCallback&lt;FileAsset&gt;): void getLastObject(callback: AsyncCallback&lt;FileAsset&gt;): void
...@@ -1712,9 +1738,9 @@ Obtains the last file asset in the result set. This API uses an asynchronous cal ...@@ -1712,9 +1738,9 @@ Obtains the last file asset in the result set. This API uses an asynchronous cal
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------ | | -------- | --------------------------------------------- | ---- | --------------------------- |
| callback | AsyncCallback&lt;[FileAsset](#fileasset8)&gt; | Yes | Callback used to return the last file asset.| | callback | AsyncCallback&lt;[FileAsset](#fileasset7)&gt; | Yes | Callback used to return the last file asset.|
**Example** **Example**
...@@ -1738,7 +1764,7 @@ async function example() { ...@@ -1738,7 +1764,7 @@ async function example() {
} }
``` ```
### getLastObject<sup>8+</sup> ### getLastObject<sup>7+</sup>
getLastObject(): Promise&lt;FileAsset&gt; getLastObject(): Promise&lt;FileAsset&gt;
...@@ -1749,8 +1775,8 @@ Obtains the last file asset in the result set. This API uses a promise to return ...@@ -1749,8 +1775,8 @@ Obtains the last file asset in the result set. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ------------- | | --------------------------------------- | ----------------- |
| Promise&lt;[FileAsset](#fileasset8)&gt; | Promise used to return the next file asset.| | Promise&lt;[FileAsset](#fileasset7)&gt; | Promise used to return the next file asset.|
**Example** **Example**
...@@ -1768,7 +1794,7 @@ async function example() { ...@@ -1768,7 +1794,7 @@ async function example() {
} }
``` ```
### getPositionObject<sup>8+</sup> ### getPositionObject<sup>7+</sup>
getPositionObject(index: number, callback: AsyncCallback&lt;FileAsset&gt;): void getPositionObject(index: number, callback: AsyncCallback&lt;FileAsset&gt;): void
...@@ -1781,7 +1807,7 @@ Obtains a file asset with the specified index in the result set. This API uses a ...@@ -1781,7 +1807,7 @@ Obtains a file asset with the specified index in the result set. This API uses a
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------ | | -------- | ---------------------------------------- | ---- | ------------------ |
| index | number | Yes | Index of the file asset to obtain. The value starts from **0**. | | index | number | Yes | Index of the file asset to obtain. The value starts from **0**. |
| callback | AsyncCallback&lt;[FileAsset](#fileasset8)&gt; | Yes | Callback used to return the last file asset.| | callback | AsyncCallback&lt;[FileAsset](#fileasset7)&gt; | Yes | Callback used to return the last file asset.|
**Example** **Example**
...@@ -1805,7 +1831,7 @@ async function example() { ...@@ -1805,7 +1831,7 @@ async function example() {
} }
``` ```
### getPositionObject<sup>8+</sup> ### getPositionObject<sup>7+</sup>
getPositionObject(index: number): Promise&lt;FileAsset&gt; getPositionObject(index: number): Promise&lt;FileAsset&gt;
...@@ -1824,8 +1850,8 @@ Obtains a file asset with the specified index in the result set. This API uses a ...@@ -1824,8 +1850,8 @@ Obtains a file asset with the specified index in the result set. This API uses a
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ------------- | | --------------------------------------- | ----------------- |
| Promise&lt;[FileAsset](#fileasset8)&gt; | Promise used to return the next file asset.| | Promise&lt;[FileAsset](#fileasset7)&gt; | Promise used to return the next file asset.|
**Example** **Example**
...@@ -1849,7 +1875,7 @@ async function example() { ...@@ -1849,7 +1875,7 @@ async function example() {
} }
``` ```
### getAllObject<sup>8+</sup> ### getAllObject<sup>7+</sup>
getAllObject(callback: AsyncCallback&lt;Array&lt;FileAsset&gt;&gt;): void getAllObject(callback: AsyncCallback&lt;Array&lt;FileAsset&gt;&gt;): void
...@@ -1863,7 +1889,7 @@ Obtains all the file assets in the result set. This API uses an asynchronous cal ...@@ -1863,7 +1889,7 @@ Obtains all the file assets in the result set. This API uses an asynchronous cal
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | -------------------- |
| callback | AsyncCallback<Array<[FileAsset](#fileasset8)>> | Yes | Callback used to return the file assets.| | callback | AsyncCallback<Array<[FileAsset](#fileasset7)>> | Yes | Callback used to return the file assets.|
**Example** **Example**
...@@ -1887,7 +1913,7 @@ async function example() { ...@@ -1887,7 +1913,7 @@ async function example() {
} }
``` ```
### getAllObject<sup>8+</sup> ### getAllObject<sup>7+</sup>
getAllObject(): Promise&lt;Array&lt;FileAsset&gt;&gt; getAllObject(): Promise&lt;Array&lt;FileAsset&gt;&gt;
...@@ -1898,8 +1924,8 @@ Obtains all the file assets in the result set. This API uses a promise to return ...@@ -1898,8 +1924,8 @@ Obtains all the file assets in the result set. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | --------------- | | ---------------------------------------- | --------------------- |
| Promise<Array<[FileAsset](#fileasset8)>> | Promise used to return the file assets.| | Promise<Array<[FileAsset](#fileasset7)>> | Promise used to return the file assets.|
**Example** **Example**
...@@ -1917,7 +1943,7 @@ async function example() { ...@@ -1917,7 +1943,7 @@ async function example() {
} }
``` ```
## Album<sup>8+</sup> ## Album<sup>7+</sup>
Provides APIs to implement a physical album. Provides APIs to implement a physical album.
...@@ -1929,11 +1955,11 @@ Provides APIs to implement a physical album. ...@@ -1929,11 +1955,11 @@ Provides APIs to implement a physical album.
| ------------ | ------ | ---- | ---- | ------- | | ------------ | ------ | ---- | ---- | ------- |
| albumId | number | Yes | No | Album ID. | | albumId | number | Yes | No | Album ID. |
| albumName | string | Yes | Yes | Album name. | | albumName | string | Yes | Yes | Album name. |
| albumUri | string | Yes | No | Album URI. | | albumUri<sup>8+</sup> | string | Yes | No | Album URI. |
| dateModified | number | Yes | No | Date when the album was modified. | | dateModified | number | Yes | No | Date when the album was modified. |
| count | number | Yes | No | Number of files in the album.| | count<sup>8+</sup> | number | Yes | No | Number of files in the album.|
| relativePath | string | Yes | No | Relative path of the album. | | relativePath<sup>8+</sup> | string | Yes | No | Relative path of the album. |
| coverUri | string | Yes | No | URI of the cover file of the album.| | coverUri<sup>8+</sup> | string | Yes | No | URI of the cover file of the album.|
### commitModify<sup>8+</sup> ### commitModify<sup>8+</sup>
...@@ -1947,8 +1973,8 @@ Commits the modification of the album attributes to the database. This API uses ...@@ -1947,8 +1973,8 @@ Commits the modification of the album attributes to the database. This API uses
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----- | | -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Void callback.| | callback | AsyncCallback&lt;void&gt; | Yes | Void callback.|
**Example** **Example**
...@@ -2007,7 +2033,7 @@ async function example() { ...@@ -2007,7 +2033,7 @@ async function example() {
} }
``` ```
### getFileAssets<sup>8+</sup> ### getFileAssets<sup>7+</sup>
getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void
...@@ -2019,10 +2045,10 @@ Obtains the file assets in this album. This API uses an asynchronous callback to ...@@ -2019,10 +2045,10 @@ Obtains the file assets in this album. This API uses an asynchronous callback to
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ | | -------- | --------------------------------------------------- | ---- | ----------------------------------- |
| options | [MediaFetchOptions](#mediafetchoptions8) | Yes | Options for fetching the files. | | options | [MediaFetchOptions](#mediafetchoptions7) | Yes | Options for fetching the files. |
| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | Yes | Callback used to return the file assets.| | callback | AsyncCallback<[FetchFileResult](#fetchfileresult7)> | Yes | Callback used to return the file assets.|
**Example** **Example**
...@@ -2041,7 +2067,7 @@ async function example() { ...@@ -2041,7 +2067,7 @@ async function example() {
} }
``` ```
### getFileAssets<sup>8+</sup> ### getFileAssets<sup>7+</sup>
getFileAssets(options?: MediaFetchOptions): Promise&lt;FetchFileResult&gt; getFileAssets(options?: MediaFetchOptions): Promise&lt;FetchFileResult&gt;
...@@ -2053,15 +2079,15 @@ Obtains the file assets in this album. This API uses a promise to return the res ...@@ -2053,15 +2079,15 @@ Obtains the file assets in this album. This API uses a promise to return the res
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------------------------- | ---- | ------ | | ------- | ---------------------------------------- | ---- | -------------- |
| options | [MediaFetchOptions](#mediafetchoptions8) | No | Options for fetching the files.| | options | [MediaFetchOptions](#mediafetchoptions7) | No | Options for fetching the files.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ------------------- | | --------------------------------------------- | ------------------------- |
| Promise<[FetchFileResult](#fetchfileresult8)> | Promise used to return the file assets.| | Promise<[FetchFileResult](#fetchfileresult7)> | Promise used to return the file assets.|
**Example** **Example**
...@@ -2087,38 +2113,36 @@ Describes information about a registered device. ...@@ -2087,38 +2113,36 @@ Describes information about a registered device.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable | Writable | Description | | Name | Type | Readable| Writable| Description |
| ---------- | ---------- | ---- | ---- | --------- | | ---------- | -------------------------- | ---- | ---- | ---------------- |
| deviceName | string | Yes | No | Name of the registered device. | | deviceName | string | Yes | No | Name of the registered device. |
| networkId | string | Yes | No | Network ID of the registered device.| | networkId | string | Yes | No | Network ID of the registered device.|
| deviceType | DeviceType | Yes | No | Type of the registered device. | | deviceType | [DeviceType](#devicetype8) | Yes | No | Type of the registered device. |
| isOnline | boolean | Yes | No | Whether the registered device is online. | | isOnline | boolean | Yes | No | Whether the registered device is online. |
MediaType ## MediaType<sup>8+</sup>
---------
Enumerates media types. Enumerates media types.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Default Value | Description | | Name | Default Value | Description|
| ----- | ---- | ---- | | ----- | ------ | ---- |
| FILE | 0 | File. | | FILE | 1 | File.|
| IMAGE | 1 | Image. | | IMAGE | 3 | Image.|
| VIDEO | 2 | Video. | | VIDEO | 4 | Video.|
| AUDIO | 3 | Audio. | | AUDIO | 5 | Audio.|
FileKey ## FileKey<sup>8+</sup>
-------
Enumerates key file information. Enumerates key file information.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Default Value | Description | | Name | Default Value | Description |
| ------------- | ------------------- | -------------------------------- | | ------------- | ------------------- | ---------------------------------------------------------- |
| ID | file_id | File ID. | | ID | file_id | File ID. |
| RELATIVE_PATH | relative_path | Relative public directory of the file. | | RELATIVE_PATH | relative_path | Relative public directory of the file. |
| DISPLAY_NAME | display_name | Display file name. | | DISPLAY_NAME | display_name | Display file name. |
...@@ -2139,15 +2163,14 @@ Enumerates key file information. ...@@ -2139,15 +2163,14 @@ Enumerates key file information.
| ALBUM_ID | bucket_id | ID 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. | | ALBUM_NAME | bucket_display_name | Name of the album to which the file belongs. |
DirectoryType ## DirectoryType<sup>8+</sup>
-------------
Enumerates directory types. Enumerates directory types.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Default Value | Description | | Name | Default Value | Description |
| ------------- | ---- | ------------ | | ------------- | ------ | ------------------ |
| DIR_CAMERA | 0 | Directory of camera files.| | DIR_CAMERA | 0 | Directory of camera files.|
| DIR_VIDEO | 1 | Directory of video files. | | DIR_VIDEO | 1 | Directory of video files. |
| DIR_IMAGE | 2 | Directory of image files. | | DIR_IMAGE | 2 | Directory of image files. |
...@@ -2155,15 +2178,14 @@ Enumerates directory types. ...@@ -2155,15 +2178,14 @@ Enumerates directory types.
| DIR_DOCUMENTS | 4 | Directory of documents. | | DIR_DOCUMENTS | 4 | Directory of documents. |
| DIR_DOWNLOAD | 5 | Download directory. | | DIR_DOWNLOAD | 5 | Download directory. |
DeviceType ## DeviceType<sup>8+</sup>
-----------
Enumerates device types. Enumerates device types.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Default Value | Description | | Name | Default Value | Description |
| ------------ | ---- | ----- | | ------------ | ------ | ---------- |
| TYPE_UNKNOWN | 0 | Unknown.| | TYPE_UNKNOWN | 0 | Unknown.|
| TYPE_LAPTOP | 1 | Laptop.| | TYPE_LAPTOP | 1 | Laptop.|
| TYPE_PHONE | 2 | Phone. | | TYPE_PHONE | 2 | Phone. |
...@@ -2172,20 +2194,20 @@ Enumerates device types. ...@@ -2172,20 +2194,20 @@ Enumerates device types.
| TYPE_CAR | 5 | Vehicle-mounted device. | | TYPE_CAR | 5 | Vehicle-mounted device. |
| TYPE_TV | 6 | TV. | | TYPE_TV | 6 | TV. |
## MediaFetchOptions<sup>8+</sup> ## MediaFetchOptions<sup>7+</sup>
Describes options for fetching media files. Describes options for fetching media files.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Readable | Writable | Mandatory | Description | | 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:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?',| | 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:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?',|
| selectionArgs | Array&lt;string&gt; | Yes | 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()], | | selectionArgs | Array&lt;string&gt; | Yes | 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()], |
| 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:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"| | order<sup>8+</sup> | 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:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"|
| uri | string | Yes | Yes | No | File URI. | | uri<sup>8+</sup> | string | Yes | Yes | No | File URI. |
| networkId | string | Yes | Yes | No | Network ID of the registered device. | | networkId<sup>8+</sup> | 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. | | extendArgs<sup>8+</sup> | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. |
## Size<sup>8+</sup> ## Size<sup>8+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册