Эх сурвалжийг харах

修复第三方打开音乐有封面的歌 没显示封面

onecold 9 сар өмнө
parent
commit
88505ec96e

+ 13 - 10
entry/src/main/ets/view/LocalMusic.ets

@@ -159,6 +159,8 @@ function getTypeOrder(type: number) {
 async function setVideoUrlForSong(song: VideoItem): Promise<string> {
   if (song.type === CommonConstants.TYPE_WEBDAV && song.webdav_account_id) {
     try {
+      Logger.info(TAG, `WebDAV完整URL构建成功remote_rel_path: ${song.remote_rel_path}`);
+      Logger.info(TAG, `WebDAV完整URL构建成功song.filePath: ${song.filePath}`);
       // 优先使用远端相对路径,其次回退到 filePath
       const relativePath = song.remote_rel_path || song.filePath;
       const fullUrl = await WebDavUrlUtil.buildFullUrlByAccountId(song.webdav_account_id, relativePath);
@@ -1263,14 +1265,13 @@ export struct LocalMusic {
     this.destroyPipController()
   }
 
-  async getSortedFiles(curPath: string, isWorkerPost?: boolean, destPath?: string, isOpen?: boolean) {
+  async getSortedFiles(curPath: string, isWorkerPost?: boolean, destPath?: string, isOpen?: boolean,openItem?:VideoItem) {
     this.isFavMusic = false
     console.info('onecold getSortedFiles 1 curPath '+curPath)
     if (isWorkerPost) {
       workerInstance.postMessage({ code: 2, data: this.context,data2:this.packName });
     }
     if (this.modeType !== 0) {
-        this.openMusic(isOpen, destPath)
       return
     }
     console.info('onecold getSortedFiles 2')
@@ -1395,7 +1396,7 @@ export struct LocalMusic {
       // }
 
       // this.setButtonStatus()
-      this.openMusic(isOpen, destPath)
+      this.openMusic(isOpen, destPath,openItem)
 
       this.isRefreshing = false
 
@@ -1405,7 +1406,7 @@ export struct LocalMusic {
   }
 
   //第三方app打开天天静听导入音乐后播放
-  openMusic(isOpen?: boolean, destPath?: string){
+  openMusic(isOpen?: boolean, destPath?: string,openItem?:VideoItem){
     if (isOpen&&destPath) {
 
       if (destPath === undefined) {
@@ -1421,9 +1422,11 @@ export struct LocalMusic {
 
         return
       }
-      let item2 = new VideoItem(Utility.getMediaNameByUri(destPath), destPath, destPath, 0, 0, '')
-      this.doPlay(item2,0,false,true)
-      this.isShowPlay = true
+      if(openItem){
+        this.doPlay(openItem,0,false,true)
+        this.isShowPlay = true
+      }
+
     }
   }
 
@@ -1932,7 +1935,7 @@ export struct LocalMusic {
     }
 
     console.info('onecold this.isCopyFileToDownLoad = ' + this.isCopyFileToDownLoad);
-    if(this.isCopyFileToDownLoad||this.currentPath==this.lockPath){
+    if(this.isCopyFileToDownLoad||this.currentPath==this.lockPath||isOpen){
       this.saveVideoDatasToDownLoad(uris,isOpen)
       return
     }
@@ -2057,7 +2060,7 @@ export struct LocalMusic {
 
               // 删除目标路径缓存
               this.cache.delete(this.currentPath);
-              this.getSortedFiles(this.currentPath, true, destPath, isOpen)
+              this.getSortedFiles(this.currentPath, true, destPath, isOpen,mediaItem)
 
             });
           }
@@ -6171,7 +6174,7 @@ export struct LocalMusic {
         this.name = this.currentSong.name
         this.cover = this.currentSong.pixelMapPath
         this.artist = this.currentSong.artist
-        LogUtil.info('this.currentSong.duration =' + this.currentSong.duration)
+        LogUtil.info('onecold this.currentSong.cover =' + this.currentSong.pixelMapPath)
         LogUtil.info('this.currentSongmimeType =' + this.currentSong.mimeType)
         this.startPlayOrResumePlay()
         break;