Răsfoiți Sursa

修复播放器背景没有更新的问题

chendeben 11 luni în urmă
părinte
comite
7a60a9e152
1 a modificat fișierele cu 23 adăugiri și 0 ștergeri
  1. 23 0
      entry/src/main/ets/view/LocalMusic.ets

+ 23 - 0
entry/src/main/ets/view/LocalMusic.ets

@@ -455,6 +455,9 @@ export struct LocalMusic {
           this.name = this.currentSong.name;
           this.artist = this.currentSong.artist;
           this.cover = this.currentSong.pixelMapPath;
+          
+          // 更新背景
+          this.updateMusicBackground();
         }
 
         LogUtils.getInstance().LOGI(`Heanup LocalMusic: Restored playlist from UnifiedPlayerService - ${this.songList.length} songs, index ${this.curIndex}, current song: ${this.currentSong?.name || 'null'}`);
@@ -1130,6 +1133,9 @@ export struct LocalMusic {
           this.name = this.currentSong.name
           this.cover = this.currentSong.pixelMapPath
           AppStorage.setOrCreate('currentSong',this.currentSong);
+          
+          // 更新背景
+          this.updateMusicBackground();
         }
 
         LogUtils.getInstance().LOGI(`Heanup LocalMusic: mkDownLoadDir - UI updated with existing playlist: ${this.songList.length} songs, current index: ${this.curIndex}, current song: ${this.currentSong?.name || 'none'}`);
@@ -12514,14 +12520,31 @@ export struct LocalMusic {
           this.scaleValueImage = 1 // 图标恢复到原始大小
           // 注意:不再手动调用 startPlayOrResumePlay(),因为 UnifiedPlayerService 已经处理了播放逻辑
         });
+        
+        // 更新背景
+        this.updateMusicBackground();
       }, 500);
     }else{
       this.cover = this.songList[this.curIndex].pixelMapPath
       // 注意:不再手动调用 startPlayOrResumePlay(),因为 UnifiedPlayerService 已经处理了播放逻辑
+      
+      // 更新背景
+      this.updateMusicBackground();
     }
 
   }
 
+  /**
+   * 更新音乐播放背景
+   */
+  private updateMusicBackground() {
+    if (this.isMusicBGCover && this.cover !== undefined && StrUtil.isNotEmpty(this.cover)) {
+      this.setImageColor2(this.cover);
+    } else {
+      this.getImageColor();
+    }
+  }
+
   // 存储已播放的歌曲索引
   private playedIndices: Set<number> = new Set();