From 9e8fa72af63aa7321149218f1431d5cb3187144d Mon Sep 17 00:00:00 2001 From: huweiqi Date: Mon, 10 Jul 2023 09:45:59 +0000 Subject: [PATCH] mediaLibrary update Signed-off-by: huweiqi Change-Id: I8bf214f86120d8194751b31f260a8a0e23bdc6b8 --- .../changelogs-mediaLibrary.md | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md index 468d7c3461..caade19501 100644 --- a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md @@ -40,7 +40,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; async function example() { try { let context = getContext(this); - let media = mediaLibrary.getmediaLibrary(context); + let media = mediaLibrary.getMediaLibrary(context); let fileKeyObj = mediaLibrary.FileKey; let albumId = 1; let getImageOp = { @@ -66,7 +66,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; async function example() { try { let context = getContext(this); - let media = mediaLibrary.getmediaLibrary(context); + let media = mediaLibrary.getMediaLibrary(context); let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { @@ -102,14 +102,15 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; async function example() { try { let context = getContext(this); - let media = mediaLibrary.getmediaLibrary(context); + let media = mediaLibrary.getMediaLibrary(context); let AlbumNoArgsfetchOp = { selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ?', selectionArgs: ['新建相册1'], // 获取albumName为新建相册1的相册。 }; - const fetchFileResult = await media.getAlbums(AlbumNoArgsfetchOp); // 查询失败,获取的fetchFileResult为空。 - const album = await fetchFileResult.getFirstObject(); - console.info('mediaLibrary album albumName: ' + album.albumName); + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); // 查询失败,获取的fetchFileResult为空。 + for (let i = 0; i < albumList.length; i++) { + console.info('mediaLibrary album albumName: ' + albumList[i].albumName); + } } catch (err) { console.error('mediaLibrary fail, err: ' + err); } @@ -126,14 +127,15 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'; async function example() { try { let context = getContext(this); - let media = mediaLibrary.getmediaLibrary(context); + let media = mediaLibrary.getMediaLibrary(context); let AlbumNoArgsfetchOp = { selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ? OR ' + mediaLibrary.FileKey.ALBUM_NAME + ' = ?', selectionArgs: ['Camera', 'Screenshots'], // 获取相机相册和截屏录屏相册。 }; - const fetchFileResult = await media.getAlbums(AlbumNoArgsfetchOp); - const album = await fetchFileResult.getFirstObject(); - console.info('mediaLibrary album albumName: ' + album.albumName); + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + for (let i = 0; i < albumList.length; i++) { + console.info('mediaLibrary album albumName: ' + albumList[i].albumName); + } } catch (err) { console.error('mediaLibrary fail, err: ' + err); } -- GitLab