Pārlūkot izejas kodu

音乐播控中心的封面显示FFmpeg获取的封面

onecold 1 gadu atpakaļ
vecāks
revīzija
4fa16ce264

+ 10 - 16
entry/src/main/ets/controller/AvSessionController.ets

@@ -132,21 +132,15 @@ export class AvSessionController {
       hilog.error(0x0000, TAG, 'SetAVMetadata Error, curSource is null');
       return;
     }
-    BackgroundTaskManager.startContinuousTask(this.context);
-    let pixelMapPath:string|undefined = curSource.pixelMapPath
+    try {
+      BackgroundTaskManager.startContinuousTask(this.context);
+      let pixelMapPath:string|undefined = curSource.pixelMapPath
 
-    Utility.getFetchMetadataFromFdSrcByPromise(curSource.filePath).then(async (value: PixelMap | undefined) => {
       let imagePixMap: PixelMap|string ;
-      if (value == undefined) {
-
-        if(pixelMapPath){
-          imagePixMap = pixelMapPath
-        }else{
-          imagePixMap = await ImageUtil.getPixelMapFromMedia($r('app.media.ic_avatar7'));
-        }
-
-      } else {
-        imagePixMap = value;
+      if(pixelMapPath){
+        imagePixMap = await ImageUtil.imagePathToPixelMap(pixelMapPath)
+      }else{
+        imagePixMap = await ImageUtil.getPixelMapFromMedia($r('app.media.ic_avatar2'));
       }
       let lyric = ''
       if(lyricContent)
@@ -171,9 +165,9 @@ export class AvSessionController {
           hilog.error(0x0000, TAG, `SetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
         });
       }
-    }).catch((err: BusinessError) => {
-      hilog.error(0x0000, TAG, `Failed to fetch metadata: code: ${err.code}, message: ${err.message}`);
-    });
+    } catch (error) {
+      console.warn(' setAVMetadataMusic:', error.message);
+    }
 
   }
 

+ 17 - 12
entry/src/main/ets/view/LocalMusic.ets

@@ -377,9 +377,9 @@ export struct LocalMusic {
     .setOnRightClickListener(() => {
       this.showSheelDialog()
     })
-    .setOnTitleClickListener(() => {
-      this.showPupDialog()
-    })
+    // .setOnTitleClickListener(() => {
+    //   this.showPupDialog()
+    // })
     .setOnLeftClickListener(() => {
       this.doSwipBack()
     })
@@ -917,7 +917,7 @@ export struct LocalMusic {
         // Utility.doSortListAscending(directories)
 
       } else {
-        if (this.currentPath === this.lockPath) {
+        if (this.currentPath === this.lockPath&&Utility.isMeidaByExtension(path)) {
           let item: VideoItem =
             await Utility.uriGetMusicAssetsFromFile(this.context, path, CommonConstants.TYPE_LOCAL, false);
           if (!path.endsWith('.lrc') && Utility.isMeidaByExtension(path) && !path.endsWith('.srt')) {
@@ -2741,7 +2741,6 @@ export struct LocalMusic {
 
   @State currentTitleName: string = '' //点击歌单,艺术家,专辑进去后的标题
   @State currentTitleCover: string | ResourceStr = '' //点击歌单,艺术家,专辑进去后的封面
-  @State currentYear:string = ''
   isShowCoverHeader() {
     if (!this.isShowHeader) {
       return false
@@ -3125,8 +3124,11 @@ export struct LocalMusic {
             if (this.isFavMusic) {
               this.getFavList(true)
             } else {
-              this.deleteCache(this.currentPath)
-              this.getSortedFiles(this.currentPath)
+              if(this.modeType == 0){
+                this.asyncCurrentPathData()
+              }else if(this.modeType ==1){
+                workerInstance.postMessage({ code: 2, data: this.context });
+              }
             }
           })
 
@@ -3449,8 +3451,8 @@ export struct LocalMusic {
       .animation({ duration: 500, curve: Curve.Ease }))
     // .margin({ bottom: this.isCoverOpacity() ? 80 : 175 })
     .margin({
-      bottom: this.isCoverOpacity() ? (this.isShowCoverHeader() ? 45 : 80)
-        : (this.isShowCoverHeader() ? 95 : 178)
+      bottom: this.isCoverOpacity() ? (this.isShowCoverHeader() ? this.topBarHeight+30 : this.topBarHeight+90)
+        : (this.isShowCoverHeader() ? this.topBarHeight+45 : this.topBarHeight+128)
     })
     .layoutWeight(1)
     .scrollBar(BarState.Off)
@@ -4085,8 +4087,8 @@ export struct LocalMusic {
       }))
     // .divider({ strokeWidth: 1, color: this.isDarkMode? '#333333':'#ffe9f0f0' })
     .margin({
-      bottom: this.isCoverOpacity() ? (this.isShowCoverHeader() ? 25 : 80)
-        : (this.isShowCoverHeader() ? 85 : this.isHiCarSmall()?140:175)
+      bottom: this.isCoverOpacity() ? (this.isShowCoverHeader() ? this.topBarHeight+25 : this.topBarHeight+80)
+        : (this.isShowCoverHeader() ? this.topBarHeight+35 : this.isHiCarSmall()?this.topBarHeight+90:this.topBarHeight+125)
     })
     .cachedCount(6)
     .borderRadius(20)
@@ -4398,7 +4400,6 @@ export struct LocalMusic {
           this.isCanBack = true
           this.titleBarModel.setTitleName(item.name)
           this.currentTitleName = '专辑:' + item.name
-          this.currentYear = '发行时间:' + albumList[0].year
           if (item.pixelMapPath) {
             this.currentTitleCover = item.pixelMapPath
           }
@@ -4406,6 +4407,10 @@ export struct LocalMusic {
           this.titleBarModel.setLeftIconMain($r('app.media.left_back_white'))
           this.mScrollMap.set(item.name, this.selectedIndex)
         }
+        //进入歌单的时候的滚动位置在顶部
+        if (this.isGridMusic) {
+          this.scroller.scrollToIndex(0)
+        }
 
         break;
       case CommonConstants.TYPE_IS_CSJAD:

+ 1 - 1
entry/src/main/resources/zh_CN/element/string.json

@@ -56,7 +56,7 @@
     },
     {
       "name": "Honey_the_video_is_playing_errant_The_system_is_wandering",
-      "value": "亲,视频播放异常"
+      "value": "亲,播放异常"
     },
     {
       "name": "ijkplayer_Audio_player",