Browse Source

修正进度时间显示

chendeben 1 year ago
parent
commit
b37c772a69

+ 2 - 2
entry/src/main/ets/common/service/PlayerManager.ets

@@ -105,8 +105,8 @@ export class PlayerManager implements IPlayerManager {
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", "100");
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-frames", "1000");
     
-    // 启动预加载
-    this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", "1");
+    // 禁用自动启动预加载,避免与手动start()调用冲突
+    this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", "0");
     
     // 设置无缓冲
     this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", "0");

+ 1 - 1
entry/src/main/ets/common/service/StateSyncService.ets

@@ -320,7 +320,7 @@ export class StateSyncService implements IStateSyncService {
         data: JSON.stringify(broadcastData)
       };
 
-      await commonEventManager.publish(PLAYER_PROGRESS_CHANGED_EVENT, publishInfo, (err) => {
+      commonEventManager.publish(PLAYER_PROGRESS_CHANGED_EVENT, publishInfo, (err) => {
         if (err) {
           hilog.error(0x0000, TAG, `Failed to broadcast progress: ${err}`);
         } else {

+ 2 - 6
entry/src/main/ets/common/service/UnifiedPlayerService.ets

@@ -190,8 +190,6 @@ async initialize(context: common.UIAbilityContext): Promise<void> {
           // 使用防抖机制更新系统播控元数据,避免频繁更新
           this.unifiedService.updateAvSessionMetadata(song);
           
-          // 移除重复的播放状态更新,让onPlaybackStarted处理
-          
           // 歌曲变化时更新卡片
           this.unifiedService.updateWidgetsForSongChange(song);
         }
@@ -2007,9 +2005,7 @@ async initialize(context: common.UIAbilityContext): Promise<void> {
       
       // 强制同步状态模型
       this.stateModel.updatePlayingState(isActuallyPlaying);
-      
-      // 只触发状态同步,让onPlaybackStarted处理系统播控更新
-      LogUtils.getInstance().LOGI('UnifiedPlayerService: AVSession state updated after player prepared');
+
     }, 100);
     
     // 播放器准备完成时更新卡片(移除加载状态)
@@ -2024,7 +2020,7 @@ async initialize(context: common.UIAbilityContext): Promise<void> {
     
     // 立即更新播放状态
     this.stateModel.updatePlayingState(true);
-    
+
     // 启动进度定时器
     this.startProgressTimer();
     

+ 96 - 87
entry/src/main/ets/view/LocalMusic.ets

@@ -274,7 +274,6 @@ export struct LocalMusic {
   @State favList: Array<VideoItem> = []
   @Consume isFavMusic: boolean
   @State isClickedPLayAll: boolean = false;
-  private scrollerForlist: ListScroller = new ListScroller();
   private knockController: KnockController | undefined = undefined;
   imagesF: ImageFrameInfo[] = [
     { src: $r("app.media.app_loading0") },
@@ -337,11 +336,6 @@ export struct LocalMusic {
     this.saveCacheToStorage()
   }
 
-  // 删除字符串缓存
-  private deleteStringCache(key: string) {
-    this.stringCache.delete(key);
-  }
-
   // 多选机制
   @State selectedFiles: Array<VideoItem> = [];
   @State isMultiSelect: boolean = false;
@@ -549,72 +543,83 @@ export struct LocalMusic {
         }
         
         onSongChanged(song: VideoItem): void {
+          console.log(`Heanup onSongChanged - 开始处理歌曲切换: ${song.name}`);
+          console.log(`Heanup onSongChanged - 切换前 oldSeconds: ${this.localMusic.oldSeconds}, currentTime: ${this.localMusic.currentTime}`);
+
+          // 立即重置时间显示状态,防止新歌曲时间显示被上一首歌曲的时间"卡住"
+          this.localMusic.oldSeconds = 0;
+          this.localMusic.currentTime = "00:00";
+          this.localMusic.lastSongPath = song.filePath; // 更新当前歌曲路径
+
+          console.log(`Heanup onSongChanged - 重置后 oldSeconds: ${this.localMusic.oldSeconds}, currentTime: ${this.localMusic.currentTime}`);
+
           // 同步当前歌曲信息
           this.localMusic.currentSong = song;
           this.localMusic.videoUrl = song.filePath;
           this.localMusic.name = song.name;
           this.localMusic.artist = song.artist;
           this.localMusic.cover = song.pixelMapPath;
-          
+
           // 更新当前索引
           const currentIndex: number = this.localMusic.unifiedPlayerService.getCurrentIndex();
           this.localMusic.curIndex = currentIndex;
-          
+
           // 同步到AppStorage,确保卡片能获取到最新状态
           AppStorage.setOrCreate('currentSong', song);
           AppStorage.setOrCreate('currIndex', currentIndex);
           AppStorage.setOrCreate('songList', this.localMusic.songList);
-          
+
           // 更新最近播放时间
           this.localMusic.updateLastPlayTimeStr(song.filePath);
-          
-          LogUtils.getInstance().LOGI(`LocalMusic: Song synchronized - ${song.name} at index ${currentIndex}`);
+
+          console.log(`Heanup onSongChanged - 歌曲切换完成: ${song.name} at index ${currentIndex}`);
+          LogUtils.getInstance().LOGI(`LocalMusic: Song synchronized - ${song.name} at index ${currentIndex} - oldSeconds=${this.localMusic.oldSeconds},currentTime=${this.localMusic.currentTime}`);
         }
-        
+
         onProgressChanged(progress: PlayProgress): void {
           // 同步进度更新到UI
           this.localMusic.syncProgressFromService(progress);
-          
+
           // 广播进度更新到卡片
           this.localMusic.broadcastProgressIfNeeded();
         }
-        
+
         onError(error: PlayerError): void {
           LogUtils.getInstance().LOGI(`UnifiedPlayerService error in LocalMusic: ${error.message}`);
           ToastUtil.showToast(`播放错误: ${error.message}`);
           this.localMusic.handlePlaybackError();
         }
       }
-      
+
       const stateListener = new LocalMusicStateListener(this);
       this.unifiedPlayerService.addStateListener(stateListener);
-      
+
       // 不设置LocalMusic自己的AVSession监听器,完全依赖UnifiedPlayerService
       // UnifiedPlayerService已经设置了AVSession监听器,状态变化会通过StateListener传播到LocalMusic
       LogUtils.getInstance().LOGI('LocalMusic: Relying on UnifiedPlayerService for AVSession handling');
-      
+
       // 初始化完成后,立即同步当前状态到UI
       setTimeout(() => {
         try {
           const currentState = this.unifiedPlayerService.getCurrentState();
           const actuallyPlaying = this.unifiedPlayerService.getActualPlayingState();
           LogUtils.getInstance().LOGI(`LocalMusic: Syncing current state - StateModel: ${currentState.isPlaying}, ActualPlayer: ${actuallyPlaying}`);
-          
+
           // 手动触发状态同步,确保UI显示正确(使用实际播放器状态)
           stateListener.onStateChanged(currentState);
         } catch (error) {
           LogUtils.getInstance().LOGI(`LocalMusic: Failed to sync current state: ${error}`);
         }
       }, 200); // 短延迟,确保组件完全初始化
-      
+
       LogUtils.getInstance().LOGI('LocalMusic: UnifiedPlayerService initialized successfully');
-      
+
       // 初始化完成后,开始加载本地文件
       this.loadLocalFilesAfterServiceInit();
     } catch (error) {
       LogUtils.getInstance().LOGI(`LocalMusic: Failed to initialize UnifiedPlayerService: ${error}`);
       ToastUtil.showToast('播放器服务初始化失败');
-      
+
       // 即使服务初始化失败,也要加载本地文件
       this.loadLocalFilesAfterServiceInit();
     }
@@ -624,15 +629,15 @@ export struct LocalMusic {
     // 加载本地文件,然后恢复播放列表
     this.getSortedFiles(this.rootPath).then(async () => {
       this.isFavMusic = false;
-      
+
       // 数据恢复已在initUnifiedPlayerService中完成,直接获取播放列表
       LogUtils.getInstance().LOGI('LocalMusic: Getting playlist from UnifiedPlayerService after file loading');
-      
+
       // 尝试从UnifiedPlayerService恢复播放列表
       const unifiedPlaylist = this.unifiedPlayerService.getPlaylist();
       const unifiedIndex = this.unifiedPlayerService.getCurrentIndex();
       const unifiedSong = this.unifiedPlayerService.getCurrentSong();
-      
+
       if (ArrayUtil.isNotEmpty(unifiedPlaylist)) {
         // 使用UnifiedPlayerService的数据
         this.songList = unifiedPlaylist;
@@ -655,11 +660,11 @@ export struct LocalMusic {
           LogUtils.getInstance().LOGI(`LocalMusic: Using legacy playlist storage - ${this.songList.length} songs, index ${this.curIndex}`);
         }
       }
-      
+
       // 同步播放列表和当前索引到AppStorage,确保卡片能访问
       AppStorage.setOrCreate('songList', this.songList);
       AppStorage.setOrCreate('currIndex', this.curIndex);
-      
+
       if (ArrayUtil.isNotEmpty(this.songList)) {
         this.isFirstStartPlay = true
         this.sonDataSource.pushArrayData(this.songList)
@@ -671,10 +676,10 @@ export struct LocalMusic {
         this.name = this.currentSong.name
         this.cover = this.currentSong.pixelMapPath
         this.artist = this.currentSong.artist
-        
+
         // 同步当前歌曲到AppStorage
         AppStorage.setOrCreate('currentSong', this.currentSong);
-        
+
         LogUtils.getInstance().LOGI(`LocalMusic: Playlist restored - ${this.songList.length} songs, current: ${this.currentSong.name}`);
       }
     });
@@ -1053,7 +1058,7 @@ export struct LocalMusic {
       // this.loadBannerAd(CSJUtil.getBannerID())
 
       LogUtils.getInstance().LOGI('LocalMusic: mkDownLoadDir - Files loaded, skipping playlist restoration (already done in initUnifiedPlayerService)');
-      
+
       // 播放列表恢复逻辑已经在 initUnifiedPlayerService 中完成,这里不需要重复
       // 只需要确保UI状态是最新的
       if (ArrayUtil.isNotEmpty(this.songList)) {
@@ -1069,7 +1074,7 @@ export struct LocalMusic {
           this.cover = this.currentSong.pixelMapPath
           AppStorage.setOrCreate('currentSong',this.currentSong);
         }
-        
+
         LogUtils.getInstance().LOGI(`LocalMusic: mkDownLoadDir - UI updated with existing playlist: ${this.songList.length} songs`);
       } else {
         this.name = '空空如也'
@@ -1355,27 +1360,27 @@ export struct LocalMusic {
         }
       }
       this.dataSource.pushArrayData(this.videoLocalList)
-      
+
       // 如果当前有播放列表,检查是否需要更新播放列表到统一播放器服务
       if (ArrayUtil.isNotEmpty(this.songList)) {
         const globalVideoList = Utility.getGlobalList(this.videoLocalList, CommonConstants.TYPE_LOCAL) as VideoItem[];
-        
+
         // 只有在没有现有播放列表时,才使用当前目录的文件列表
         // 避免在文件列表更新时破坏用户的播放列表
         if (ArrayUtil.isEmpty(this.songList) && ArrayUtil.isNotEmpty(globalVideoList)) {
           this.songList = globalVideoList;
           AppStorage.setOrCreate('songList', this.songList);
           this.sonDataSource.pushArrayData(this.songList);
-          
+
           // 同步到统一播放器服务进行持久化
           this.syncPlaylistToService();
-          
+
           LogUtils.getInstance().LOGI(`LocalMusic: updateListData - Created initial playlist with ${this.songList.length} songs`);
         } else {
           LogUtils.getInstance().LOGI(`LocalMusic: updateListData - Preserving existing playlist with ${this.songList.length} songs, current directory has ${globalVideoList.length} songs`);
         }
       }
-      
+
       animateTo({ duration: 888 }, () => {
         this.opacityItem = 1;
       });
@@ -4780,10 +4785,10 @@ export struct LocalMusic {
           // 点击文件列表中的歌曲,需要判断是否要创建新的播放列表
           let globalVideoList = Utility.getGlobalList(this.videoLocalList, CommonConstants.TYPE_LOCAL) as VideoItem[];
           this.curIndex = Utility.getCurIndexFromGlobalList(globalVideoList, item.filePath)
-          
+
           // 检查当前播放列表是否包含这首歌
           const currentSongIndex = this.songList.findIndex(song => song.filePath === item.filePath);
-          
+
           if (currentSongIndex >= 0 && ArrayUtil.isNotEmpty(this.songList)) {
             // 如果当前播放列表已经包含这首歌,使用现有播放列表
             this.curIndex = currentSongIndex;
@@ -4801,7 +4806,7 @@ export struct LocalMusic {
         AppStorage.setOrCreate('currentSong',this.currentSong) ;
         AppStorage.setOrCreate('songList', this.songList);
         AppStorage.setOrCreate('currIndex', this.curIndex);
-        
+
         this.videoUrl = this.currentSong.filePath
         this.name = this.currentSong.name
         this.cover = this.currentSong.pixelMapPath
@@ -4809,7 +4814,7 @@ export struct LocalMusic {
 
         // 同步播放列表到UnifiedPlayerService
         this.syncPlaylistToService();
-        
+
         LogUtil.info('this.currentSong.duration =' + this.currentSong.duration)
         LogUtil.info('this.currentSong.sampleRate =' + this.currentSong.sampleRate)
         LogUtil.info('this.currentSongmimeType =' + this.currentSong.mimeType)
@@ -5921,30 +5926,30 @@ export struct LocalMusic {
     if (newIndex < 0 || newIndex >= this.songList.length) {
       return;
     }
-    
+
     try {
       // 使用UnifiedPlayerService进行播放列表重排序
       const removedSong = this.unifiedPlayerService.removeFromPlaylist(index);
       if (removedSong) {
         this.unifiedPlayerService.addToPlaylist(removedSong, newIndex);
       }
-      
+
       // 更新本地播放列表
       let tmp = this.songList.splice(index, 1);
       this.songList.splice(newIndex, 0, tmp[0]);
       this.sonDataSource.pushArrayData(this.songList);
-      
+
       // 更新当前索引
       this.curIndex = Utility.getIndexFromList(this.songList, this.videoUrl);
-      
+
       // 同步到AppStorage
       AppStorage.setOrCreate('songList', this.songList);
       AppStorage.setOrCreate('currIndex', this.curIndex);
-      
+
       LogUtils.getInstance().LOGI(`LocalMusic: Moved song from ${index} to ${newIndex} via UnifiedPlayerService`);
     } catch (error) {
       LogUtils.getInstance().LOGI(`LocalMusic itemMoveSon error: ${error}`);
-      
+
       // 错误处理:回退到原有逻辑
       let tmp = this.songList.splice(index, 1);
       this.songList.splice(newIndex, 0, tmp[0]);
@@ -6206,13 +6211,13 @@ export struct LocalMusic {
           // 使用更低的阈值和滑动速度判断
           const minDistance = 100; // 最小滑动距离 100vp
           const minVelocity = 500; // 最小滑动速度
-          
+
           // 获取滑动速度(如果可用)
           const velocity = event?.velocityY || 0;
-          
+
           // 判断是否应该关闭:距离足够 或者 速度足够快
           const shouldClose = this.translateY > minDistance || velocity > minVelocity;
-          
+
           if (shouldClose) {
             // 添加关闭动画
             this.getUIContext().animateTo({
@@ -6580,6 +6585,7 @@ export struct LocalMusic {
   @State oldSeconds: number = 0;
   @State isSeekTo: boolean = false;
   @State isCurrentTime: boolean = false;
+  @State lastSongPath: string = ""; // 用于检测歌曲切换
   @State videoWidth: string = '100%';
   @State videoHeight: string = '100%';
   @State initAspectRatio: number = 1;
@@ -6599,14 +6605,6 @@ export struct LocalMusic {
   @State playType: number = 0; //0:连续播放  1:单片重复播放 2:正常播放 3:随机播放
   @State multiple: string = '1.0X';
   xcomponentController: XComponentController = new XComponentController()
-  private panOptionBright: PanGestureOptions =
-    new PanGestureOptions({ direction: PanDirection.Up | PanDirection.Down });
-  private panOptionVolume: PanGestureOptions =
-    new PanGestureOptions({ direction: PanDirection.Vertical | PanDirection.Up | PanDirection.Down });
-  private panOptionSeekTo: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.Horizontal });
-  //手势的音量控制和亮度控制
-  private positionX: number = PlayConstants.POSITION_X;
-  private positionY: number = PlayConstants.POSITION_Y;
   private windowClass: window.Window = globalThis.windowClass
   @State volume: number = 0.3;
   @State volumeShow: boolean = PlayConstants.VOLUME_SHOW;
@@ -7161,14 +7159,14 @@ export struct LocalMusic {
     //   return
     // }
     const isPlaying = this.CONTROL_PlayStatus === PlayStatus.PLAY;
-    
+
     // 同步所有播放状态
     this.setIsPlaying(isPlaying);
     this.animationState = isPlaying ? AnimationStatus.Running : AnimationStatus.Paused;
-    
+
     // 记录状态变化日志
     LogUtils.getInstance().LOGI(`LocalMusic: playChange - CONTROL_PlayStatus: ${this.CONTROL_PlayStatus}, isPlaying: ${isPlaying}, globalIsPlaying: ${this.isPlaying}`);
-    
+
     // 强制触发UI刷新 - 这对于@State变量应该是自动的,但我们确保一下
     setTimeout(() => {
       LogUtils.getInstance().LOGI(`LocalMusic: UI refresh triggered - CONTROL_PlayStatus: ${this.CONTROL_PlayStatus}`);
@@ -7179,7 +7177,7 @@ export struct LocalMusic {
   public forceSyncState(): void {
     const currentState = this.unifiedPlayerService.getCurrentState();
     LogUtils.getInstance().LOGI(`LocalMusic: Force sync - UnifiedPlayerService state: isPlaying=${currentState.isPlaying}, isPaused=${currentState.isPaused}`);
-    
+
     // 手动触发状态同步
     if (currentState.isPlaying) {
       this.CONTROL_PlayStatus = PlayStatus.PLAY;
@@ -7188,10 +7186,10 @@ export struct LocalMusic {
     } else {
       this.CONTROL_PlayStatus = PlayStatus.INIT;
     }
-    
+
     this.setIsPlaying(currentState.isPlaying);
     this.playChange();
-    
+
     LogUtils.getInstance().LOGI(`LocalMusic: Force sync completed - CONTROL_PlayStatus: ${this.CONTROL_PlayStatus}`);
   }
 
@@ -9743,36 +9741,36 @@ export struct LocalMusic {
       this.mDestroyPage = false;
       this.animationState = AnimationStatus.Running
       LogUtils.getInstance().LOGI("startPlayOrResumePlay start this.CONTROL_PlayStatus:" + this.CONTROL_PlayStatus)
-      
+
       // 确保播放列表已同步到UnifiedPlayerService
       if (ArrayUtil.isNotEmpty(this.songList)) {
         this.unifiedPlayerService.setPlaylist(this.songList, this.curIndex);
       }
-      
+
       // 使用UnifiedPlayerService开始播放
       await this.unifiedPlayerService.startPlayOrResumePlay();
-      
+
       // 保持原有的UI更新逻辑
       this.stopProgressTask();
       this.startProgressTask();
       this.watchStatus();
       this.updateLastPlayTimeStr(this.videoUrl)
-      
+
       // 更新播放状态
       this.CONTROL_PlayStatus = PlayStatus.PLAY;
       this.setIsPlaying(true);
       this.updateSessionPlayState(true);
-      
+
       LogUtils.getInstance().LOGI("LocalMusic: startPlayOrResumePlay completed via UnifiedPlayerService");
     } catch (error) {
       LogUtils.getInstance().LOGI(`LocalMusic startPlayOrResumePlay error: ${error}`);
       ToastUtil.showToast(`播放失败: ${error}`);
-      
+
       // 错误处理:回退到原有逻辑
       this.handlePlaybackError();
     }
   }
-  
+
   // 播放错误处理
   private handlePlaybackError() {
     this.CONTROL_PlayStatus = PlayStatus.INIT;
@@ -9826,14 +9824,14 @@ export struct LocalMusic {
     try {
       // 确保播放列表已同步到UnifiedPlayerService
       this.unifiedPlayerService.setPlaylist(this.songList, this.curIndex);
-      
+
       // 使用UnifiedPlayerService播放指定索引的歌曲
       await this.unifiedPlayerService.playSongAtIndex(index);
-      
+
       // 更新本地状态以保持UI同步
       const currentIndex = this.unifiedPlayerService.getCurrentIndex();
       const currentSong = this.unifiedPlayerService.getCurrentSong();
-      
+
       if (currentSong) {
         this.curIndex = currentIndex;
         this.currentSong = currentSong;
@@ -9841,19 +9839,19 @@ export struct LocalMusic {
         this.name = currentSong.name;
         this.artist = currentSong.artist;
         this.cover = currentSong.pixelMapPath;
-        
+
         // 同步到AppStorage
         AppStorage.setOrCreate('songList', this.songList);
         AppStorage.setOrCreate('currIndex', this.curIndex);
         AppStorage.setOrCreate('currentSong', currentSong);
 
       }
-      
+
       LogUtils.getInstance().LOGI(`LocalMusic: playSongAtIndex ${index} completed via UnifiedPlayerService`);
     } catch (error) {
       LogUtils.getInstance().LOGI(`LocalMusic playSongAtIndex error: ${error}`);
       ToastUtil.showToast(`播放歌曲失败: ${error}`);
-      
+
       // 错误处理:回退到原有逻辑
       this.playIndex(index);
     }
@@ -9866,10 +9864,10 @@ export struct LocalMusic {
         // 记录调用栈信息以便调试
         const stack = new Error().stack || 'No stack available';
         const caller = stack.split('\n')[2] || 'Unknown caller';
-        
+
         this.unifiedPlayerService.setPlaylist(this.songList, this.curIndex);
         LogUtils.getInstance().LOGI(`LocalMusic: Playlist synced to UnifiedPlayerService - ${this.songList.length} songs, caller: ${caller.trim()}`);
-        
+
         // 如果同步的是小播放列表,记录更多信息
         if (this.songList.length <= 20) {
           LogUtils.getInstance().LOGI(`LocalMusic: Small playlist sync detected, current path: ${this.currentPath}, first few songs: ${this.songList.slice(0, 5).map(s => s.name).join(', ')}`);
@@ -9887,26 +9885,26 @@ export struct LocalMusic {
     try {
       // 使用UnifiedPlayerService移除歌曲
       const removedSong = this.unifiedPlayerService.removeFromPlaylist(index);
-      
+
       if (removedSong) {
         // 更新本地播放列表
         this.songList.splice(index, 1);
         this.sonDataSource.pushArrayData(this.songList);
-        
+
         // 更新当前索引
         this.curIndex = this.unifiedPlayerService.getCurrentIndex();
-        
+
         // 同步到AppStorage
         AppStorage.setOrCreate('songList', this.songList);
         AppStorage.setOrCreate('currIndex', this.curIndex);
-        
+
         ToastUtil.showToast(`已移除 ${removedSong.name}`);
-        
+
         LogUtils.getInstance().LOGI(`LocalMusic: Removed song at index ${index} via UnifiedPlayerService - ${removedSong.name}`);
       }
     } catch (error) {
       LogUtils.getInstance().LOGI(`LocalMusic removeFromPlaylistViaService error: ${error}`);
-      
+
       // 错误处理:回退到原有逻辑
       if (index >= 0 && index < this.songList.length) {
         const removedSong = this.songList.splice(index, 1)[0];
@@ -9919,6 +9917,16 @@ export struct LocalMusic {
   // 同步进度更新到UI(从UnifiedPlayerService)
   private syncProgressFromService(progress: PlayProgress) {
     try {
+      // 检测歌曲是否发生切换(额外保障机制)
+      const currentSongPath = this.currentSong?.filePath || "";
+      if (this.lastSongPath !== currentSongPath && currentSongPath !== "") {
+        console.log(`Heanup 在进度更新中检测到歌曲切换: ${this.lastSongPath} -> ${currentSongPath}`);
+        console.log(`Heanup 歌曲切换前 oldSeconds: ${this.oldSeconds}`);
+        this.oldSeconds = 0;
+        this.lastSongPath = currentSongPath;
+        console.log(`Heanup 歌曲切换后 oldSeconds: ${this.oldSeconds}`);
+      }
+
       // 更新进度条
       if (progress.duration > 0) {
         this.slideEnable = true;
@@ -9936,10 +9944,12 @@ export struct LocalMusic {
       if (progress.currentPosition > progress.duration) {
         progress.currentPosition = progress.duration;
       }
-      
+      console.log(`Heanup 当前时间 - ${progress.currentPosition} / ${progress.duration}`)
+      console.log(`Heanup 更新前 - oldSeconds: ${this.oldSeconds}, currentTime: ${this.currentTime}`)
       this.isCurrentTime = true;
       this.currentTime = this.stringForTime(progress.currentPosition);
       this.isCurrentTime = false;
+      console.log(`Heanup 更新后 - oldSeconds: ${this.oldSeconds}, currentTime: ${this.currentTime}`)
 
       // 更新歌词位置
       const lyricPosition = progress.currentPosition + this.timeOffset * 1000;
@@ -10856,13 +10866,12 @@ export struct LocalMusic {
         }, () => {
           this.opacityValueImage = 1;
           this.scaleValueImage = 1 // 图标恢复到原始大小
-          this.startPlayOrResumePlay()
+          // 注意:不再手动调用 startPlayOrResumePlay(),因为 UnifiedPlayerService 已经处理了播放逻辑
         });
       }, 500);
     }else{
       this.cover = this.songList[this.curIndex].pixelMapPath
-      this.startPlayOrResumePlay()
-
+      // 注意:不再手动调用 startPlayOrResumePlay(),因为 UnifiedPlayerService 已经处理了播放逻辑
     }
 
   }