提交 c4410157 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 f30f79c3
...@@ -20,6 +20,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal ...@@ -20,6 +20,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal
This API can be used only in the stage model. This API can be used only in the stage model.
> **NOTE** > **NOTE**
>
> This API is deprecated since API version 9. Use [getPhotoAccessHelper](js-apis-photoAccessHelper.md#photoaccesshelpergetphotoaccesshelper) instead. > This API is deprecated since API version 9. Use [getPhotoAccessHelper](js-apis-photoAccessHelper.md#photoaccesshelpergetphotoaccesshelper) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -44,7 +45,7 @@ const context = getContext(this); ...@@ -44,7 +45,7 @@ const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context); let media = mediaLibrary.getMediaLibrary(context);
``` ```
**Example (API version 8)** **Example (from API version 8)**
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
...@@ -62,6 +63,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal ...@@ -62,6 +63,7 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal
This API can be used only in the FA model. This API can be used only in the FA model.
> **NOTE** > **NOTE**
>
> This API is deprecated since API version 9. There is no substitute API. > This API is deprecated since API version 9. There is no substitute API.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
...@@ -344,7 +346,7 @@ Creates a media asset. This API uses a promise to return the result. ...@@ -344,7 +346,7 @@ Creates a media asset. This API uses a promise to return the result.
| ------------ | ------------------------ | ---- | ------------------------------------------------------------ | | ------------ | ------------------------ | ---- | ------------------------------------------------------------ |
| mediaType | [MediaType](#mediatype8) | Yes | Media type. | | mediaType | [MediaType](#mediatype8) | Yes | Media type. |
| displayName | string | Yes | File name to display. | | displayName | string | Yes | File name to display. |
| relativePath | string | Yes | Relative path of the file, which can be obtained by [getPublicDirectory](#getpublicdirectory8).| | relativePath | string | Yes | Relative path of the file, which can be obtained by **getPublicDirectory**.|
**Return value** **Return value**
...@@ -557,7 +559,7 @@ Obtains albums. This API uses an asynchronous callback to return the result. ...@@ -557,7 +559,7 @@ Obtains albums. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
> - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums) instead. > - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums) instead.
> - 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). > - 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 details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA **Required permissions**: ohos.permission.READ_MEDIA
...@@ -597,7 +599,7 @@ Obtains albums. This API uses a promise to return the result. ...@@ -597,7 +599,7 @@ Obtains albums. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums-2) instead. > - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums-2) instead.
> - 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). > - 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 details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA **Required permissions**: ohos.permission.READ_MEDIA
...@@ -666,6 +668,7 @@ Releases this **MediaLibrary** instance. ...@@ -666,6 +668,7 @@ Releases this **MediaLibrary** instance.
Call this API when you no longer need to use the APIs in the **MediaLibrary** instance. Call this API when you no longer need to use the APIs in the **MediaLibrary** instance.
> **NOTE** > **NOTE**
>
> This API is deprecated since API version 9. Use [release](js-apis-photoAccessHelper.md#release-1) instead. > This API is deprecated since API version 9. Use [release](js-apis-photoAccessHelper.md#release-1) instead.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core **System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......
...@@ -1433,37 +1433,35 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err ...@@ -1433,37 +1433,35 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err
import dataSharePredicates from '@ohos.data.dataSharePredicates'; import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() { async function example() {
console.info('getPhotoIndexDemo'); try {
let predicatesForGetAsset = new dataSharePredicates.DataSharePredicates(); console.info('getPhotoIndexDemo');
let fetchOp = { let predicatesForGetAsset = new dataSharePredicates.DataSharePredicates();
fetchColumns: [], let fetchOp = {
predicates: predicatesForGetAsset fetchColumns: [],
}; predicates: predicatesForGetAsset
//Obtain the uri of the album };
let albumFetchResult = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubtype.FAVORITE, fetchOp); // Obtain the uri of the album
let album = await albumFetchResult.getFirstObject(); let albumFetchResult = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.FAVORITE, fetchOp);
let album = await albumFetchResult.getFirstObject();
let predicates = new dataSharePredicates.DataSharePredicates(); let predicates = new dataSharePredicates.DataSharePredicates();
predicates.orderByAsc("add_modified"); predicates.orderByAsc(userFileManager.ImageVideoKey.DATE_MODIFIED);
let fetchOptions = { let fetchOptions = {
fetchColumns: [], fetchColumns: [userFileManager.ImageVideoKey.DATE_MODIFIED],
predicates: predicates predicates: predicates
}; };
let photoFetchResult = await album.getPhotoAssets(fetchOptions); let photoFetchResult = await album.getPhotoAssets(fetchOptions);
let expectIndex = 1; let expectIndex = 1;
//Obtain the uri of the second file // Obtain the uri of the second file
let photoAsset = await photoFetchResult.getPositionObject(expectIndex); let photoAsset = await photoFetchResult.getPositionObject(expectIndex);
mgr.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions, (err, index) => {
mgr.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions, (err, index) => {
try {
if (err == undefined) { if (err == undefined) {
console.info(`getPhotoIndex successfully and index is : ${index}`); console.info(`getPhotoIndex successfully and index is : ${index}`);
} else { } else {
console.info(`getPhotoIndex failed;`); console.info(`getPhotoIndex failed;`);
} }
} catch (error) { });
console.info(`getPhotoIndex failed; error: ${error}`); } catch (error) {
} console.info(`getPhotoIndex failed; error: ${error}`);
} }
} }
``` ```
...@@ -1508,33 +1506,34 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err ...@@ -1508,33 +1506,34 @@ For details about the error codes, see [Universal Error Codes](../errorcodes/err
import dataSharePredicates from '@ohos.data.dataSharePredicates'; import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() { async function example() {
console.info('getPhotoIndexDemo'); try {
let predicatesForGetAsset = new dataSharePredicates.DataSharePredicates(); console.info('getPhotoIndexDemo');
let fetchOp = { let predicatesForGetAsset = new dataSharePredicates.DataSharePredicates();
fetchColumns: [], let fetchOp = {
predicates: predicatesForGetAsset fetchColumns: [],
}; predicates: predicatesForGetAsset
//Obtain the uri of the album };
let albumFetchResult = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubtype.FAVORITE, fetchOp); // Obtain the uri of the album
let album = await albumFetchResult.getFirstObject(); let albumFetchResult = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubType.FAVORITE, fetchOp);
let album = await albumFetchResult.getFirstObject();
let predicates = new dataSharePredicates.DataSharePredicates(); let predicates = new dataSharePredicates.DataSharePredicates();
predicates.orderByAsc("add_modified"); predicates.orderByAsc(userFileManager.ImageVideoKey.DATE_MODIFIED);
let fetchOptions = { let fetchOptions = {
fetchColumns: [], fetchColumns: [userFileManager.ImageVideoKey.DATE_MODIFIED],
predicates: predicates predicates: predicates
}; };
let photoFetchResult = await album.getPhotoAssets(fetchOptions); let photoFetchResult = await album.getPhotoAssets(fetchOptions);
let expectIndex = 1; let expectIndex = 1;
//Obtain the uri of the second file // Obtain the uri of the second file
let photoAsset = await photoFetchResult.getPositionObject(expectIndex); let photoAsset = await photoFetchResult.getPositionObject(expectIndex);
mgr.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions).then((index) => {
mgr.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions) console.info(`getPhotoIndex successfully and index is : ${index}`);
.then((index) => { }).catch((err) => {
console.info(`getPhotoIndex successfully and index is : ${index}`);
}).catch((err) => {
console.info(`getPhotoIndex failed; error: ${err}`); console.info(`getPhotoIndex failed; error: ${err}`);
}) });
} catch (error) {
console.info(`getPhotoIndex failed; error: ${error}`);
}
} }
``` ```
...@@ -2565,15 +2564,18 @@ async function example() { ...@@ -2565,15 +2564,18 @@ async function example() {
try { try {
console.info('getExifDemo'); console.info('getExifDemo');
let predicates = new dataSharePredicates.DataSharePredicates(); let predicates = new dataSharePredicates.DataSharePredicates();
predicates.isNotNull('all_exif')
let fetchOptions = { let fetchOptions = {
fetchColumns: [ 'all_exif', ImageVideoKey.USER_COMMENT], fetchColumns: ['all_exif', userFileManager.ImageVideoKey.USER_COMMENT],
predicates: predicates predicates: predicates
}; };
let fetchResult = await mgr.getPhotoAssets(fetchOptions); let fetchResult = await mgr.getPhotoAssets(fetchOptions);
let fileAsset = await fetchResult.getFirstObject(); let fileAsset = await fetchResult.getFirstObject();
console.info('getExifDemo fileAsset displayName: ' + JSON.stringify(fileAsset.displayName));
let exifMessage = await fileAsset.getExif(); let exifMessage = await fileAsset.getExif();
let userCommentKey = 'UserComment'; let userCommentKey = 'UserComment';
let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]); let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]);
console.info('getExifDemo userComment: ' + JSON.stringify(userComment));
fetchResult.close(); fetchResult.close();
} catch (err) { } catch (err) {
console.error('getExifDemoCallback failed with error: ' + err); console.error('getExifDemoCallback failed with error: ' + err);
...@@ -2651,16 +2653,19 @@ async function example() { ...@@ -2651,16 +2653,19 @@ async function example() {
try { try {
console.info('getExifDemo'); console.info('getExifDemo');
let predicates = new dataSharePredicates.DataSharePredicates(); let predicates = new dataSharePredicates.DataSharePredicates();
predicates.isNotNull('all_exif')
let fetchOptions = { let fetchOptions = {
fetchColumns: [ 'all_exif', ImageVideoKey.USER_COMMENT], fetchColumns: ['all_exif', userFileManager.ImageVideoKey.USER_COMMENT],
predicates: predicates predicates: predicates
}; };
let fetchResult = await mgr.getPhotoAssets(fetchOptions); let fetchResult = await mgr.getPhotoAssets(fetchOptions);
let fileAsset = await fetchResult.getFirstObject(); let fileAsset = await fetchResult.getFirstObject();
console.info('getExifDemo fileAsset displayName: ' + JSON.stringify(fileAsset.displayName));
let userCommentKey = 'UserComment'; let userCommentKey = 'UserComment';
fileAsset.getExif((err, exifMessage) => { fileAsset.getExif((err, exifMessage) => {
if (exifMessage != undefined) { if (exifMessage != undefined) {
let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]); let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]);
console.info('getExifDemo userComment: ' + JSON.stringify(userComment));
} else { } else {
console.error('getExif failed, message = ', err); console.error('getExif failed, message = ', err);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册