From 285893512fca07858671305f87cde64684032d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=82=A6?= Date: Thu, 20 Oct 2022 20:25:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王悦 --- entry/src/main/ets/pages/videoFile.ets | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/entry/src/main/ets/pages/videoFile.ets b/entry/src/main/ets/pages/videoFile.ets index 3ec40ce..6fb5af3 100644 --- a/entry/src/main/ets/pages/videoFile.ets +++ b/entry/src/main/ets/pages/videoFile.ets @@ -6,6 +6,7 @@ import worker from '@ohos.worker' import ButtomView from '../Components/BottomView'; import mediaLibrary from '@ohos.multimedia.mediaLibrary'; import prompt from '@system.prompt'; +import MediaUtils from '../Model/MediaUtils'; @Entry @Component @@ -39,35 +40,13 @@ struct AudioFile { path: router.getParams()['videoPath'] }) } - /* - * 获取选中资源 - * - *return fileAsset and fd - */ - - async getSelectFileAsset(title){ - let fileKeyObj = mediaLibrary.FileKey; - let fetchOp = { - selections: fileKeyObj.TITLE + '= ?', - selectionArgs: [title.toString()], - order: fileKeyObj.DATE_ADDED + " DESC", - } - console.log('hans----..,,..:'+title) - - let fetchFileResult = await mediaLibrary.getMediaLibrary(globalThis.context).getFileAssets(fetchOp); - console.log('hans----..,,..'+fetchFileResult.getCount()) - - let fileAsset = await fetchFileResult.getFirstObject(); - console.log('hans----..,,..') - return fileAsset - } /* * 修改名字 * */ async renameOrTitle(newTitle) { let nameList = this.selectVideo.name.split('.') - let fileAsset = await this.getSelectFileAsset(nameList[0]) + let fileAsset = await MediaUtils.getInstance().getSelectFileAsset(nameList[0]) if (fileAsset) { fileAsset.title = newTitle//把刚改完的文件名赋给从媒体库获取的文件 fileAsset.displayName = newTitle+'.'+nameList[1] -- Gitee