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