Explorar o código

LocalMusic转圈圈的问题

onecold hai 5 meses
pai
achega
27d98be026

+ 7 - 10
entry/src/main/ets/pages/WebDavMainPage.ets

@@ -2690,19 +2690,16 @@ export struct WebDavMainPage {
       if (this.webdavManager.currentPath !== '') {
         Row({ space: 8 }) {
           Button({ type: ButtonType.Circle }) {
-            // Image(this.webdavManager.canGoBack()?$r('app.media.back'):
-            //   this.selectedAccount.coverPath?this.selectedAccount.coverPath:getCloudDiskIcon(this.selectedAccount.webType))
-            Image(this.selectedAccount.coverPath)
-              .width(15)
-              .height(15)
-              .borderRadius(10)
+            Image(this.selectedAccount.coverPath?
+              this.selectedAccount.coverPath:getCloudDiskIcon(this.selectedAccount.webType))
+              .width(18)
+              .height(18)
               .alt($r('app.media.cloudDisk'))
-              .fillColor(Color.White)
           }
-          .width(20)
-          .height(20)
+          .width(24)
+          .height(24)
+          .backgroundColor('#EFEFEF')
           .margin({left:5})
-          .backgroundColor(this.themeColor)
           .onClick(() => this.goBack())
 
           Row({ space: 4 }) {

+ 72 - 11
entry/src/main/ets/view/LocalMusic.ets

@@ -7479,8 +7479,12 @@ export struct LocalMusic {
         await this.hydrateRemoteSongFromDb(this.currentSong);
         AppStorage.setOrCreate('currentSong', this.currentSong);
 
+        const remotePlayLoading = this.beginRemoteSongSwitchLoading(this.currentSong);
         const playbackUrl = await this.resolvePlaybackUrlForCurrentSong('doPlay-remote');
         if (!playbackUrl) {
+          if (remotePlayLoading) {
+            this.hideLoadIng();
+          }
           return;
         }
         this.videoUrl = playbackUrl;
@@ -12168,8 +12172,8 @@ export struct LocalMusic {
           this.PlayOrPauseButton()
         },
         isPx: false,
-        builderHeight: this.isPhoneLan()?38:42,
-        builderWidth: this.isPhoneLan()?38:42,
+        builderHeight: this.isPhoneLan()?40:43,
+        builderWidth: this.isPhoneLan()?40:43,
       })
         .onClick(() =>{
           this.playOrPause()
@@ -12218,7 +12222,7 @@ export struct LocalMusic {
         Image(this.CONTROL_PlayStatus === PlayStatus.PLAY ?
           (this.isCircleBtn?$r('app.media.hm_pause'):$r('app.media.ic_public_play'))
           : (this.isCircleBtn?$r('app.media.hm_play2'):$r('app.media.ic_public_pause')))
-          .width(this.isPhoneLan()?38:42)
+          .width(this.isPhoneLan()?38:40)
           .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
           .fillColor(Color.White)
           .aspectRatio(CommonConstants.ASPECT_RATIO)
@@ -12227,14 +12231,14 @@ export struct LocalMusic {
       // 加载进度圈
       if (this.isPlayerLoading) {
         Progress({value:0,total:100,type:ProgressType.Ring })
-          .width(this.isPhoneLan()?40:44)
-          .height(this.isPhoneLan()?40:44)
+          .width(this.isPhoneLan()?40:43)
+          .height(this.isPhoneLan()?40:43)
           .color(Color.White)
-          .style({ strokeWidth: 4, status: ProgressStatus.LOADING })
+          .style({ strokeWidth: 5, status: ProgressStatus.LOADING })
       }
     }
-    .width(this.isPhoneLan()?39:43)
-    .height(this.isPhoneLan()?39:43)
+    .width(this.isPhoneLan()?40:43)
+    .height(this.isPhoneLan()?40:43)
   }
 
 
@@ -14592,7 +14596,7 @@ export struct LocalMusic {
 
     { id: 25, image: $r('sys.symbol.ranking'), title: '音乐频谱' },
     { id: 26, image: $r('sys.symbol.eight_diagram'), title: '频谱类型' },
-    // { id: 6, image: $r('app.media.memory'), title: '记忆播放' },
+    { id: 6, image: $r('app.media.memory'), title: '记忆播放' },
 
 
     { id: 13, image: $r('app.media.rectangle'), title: '封面方形' },
@@ -15407,8 +15411,8 @@ export struct LocalMusic {
       const isRemoteStreamSong = this.currentSong && isRemoteCloudType(this.currentSong.type) &&
         this.videoUrl.includes('://');
       this.waitInitialSeekBeforeStart = !!isRemoteStreamSong && this.pendingMemorySeekPosition > 0;
-      // 判断是否是HTTP或在线网盘视频,显示加载进度
-      this.isPlayerLoading = this.waitInitialSeekBeforeStart;
+      // 网盘歌曲起播阶段统一显示加载圈,prepared/首帧后再收起
+      this.isPlayerLoading = !!isRemoteStreamSong;
       if (this.currentSong && isRemoteCloudType(this.currentSong.type)) {
         Logger.info(
           TAG,
@@ -15767,20 +15771,31 @@ export struct LocalMusic {
   }
 
   private showLoadIng() {
+    this.isPlayerLoading = true;
     this.loadingVisible = Visibility.Visible;
     this.replayVisible = Visibility.None;
   }
 
   private hideLoadIng() {
+    this.isPlayerLoading = false;
     this.loadingVisible = Visibility.None;
     this.replayVisible = Visibility.None;
   }
 
   private showRePlay() {
+    this.isPlayerLoading = false;
     this.loadingVisible = Visibility.None;
     this.replayVisible = Visibility.Visible;
   }
 
+  private beginRemoteSongSwitchLoading(song?: VideoItem): boolean {
+    const shouldShow = !!song && isRemoteCloudType(song.type);
+    if (shouldShow) {
+      this.showLoadIng();
+    }
+    return shouldShow;
+  }
+
   private clearInitialSeekGuardTimer(): void {
     if (this.initialSeekGuardTimer) {
       clearTimeout(this.initialSeekGuardTimer);
@@ -17645,8 +17660,12 @@ export struct LocalMusic {
       // 直接使用歌曲列表中的歌曲信息,songList中的数据已经是完整的
       this.currentSong = this.songList[this.curIndex];
       console.info('heanup playNext', `直接使用歌曲列表中的信息: ${this.currentSong.name}, type: ${this.currentSong.type}`);
+      const nextLoading = this.beginRemoteSongSwitchLoading(this.currentSong);
       const nextUrl = await this.resolvePlaybackUrlForCurrentSong('playNext');
       if (!nextUrl) {
+        if (nextLoading) {
+          this.hideLoadIng();
+        }
         return;
       }
       this.videoUrl = nextUrl;
@@ -17672,6 +17691,9 @@ export struct LocalMusic {
           this.updateCastProgress(0);
           await this.castControllerWrapper.playNext(this.songList, this.curIndex, this.videoUrl, nextDuration);
           this.isCastPlaying = this.castControllerWrapper.getIsCastPlaying();
+          if (nextLoading) {
+            this.hideLoadIng();
+          }
           console.info('heanup playNext', 'CastController 播放下一首成功');
           return;
         } catch (error) {
@@ -17684,6 +17706,9 @@ export struct LocalMusic {
       // 本地播放器模式,需要先stop
       this.CONTROL_PlayStatus = PlayStatus.INIT;
       this.stop();
+      if (nextLoading) {
+        this.showLoadIng();
+      }
       this.changeImageAnimation()
     }
   }
@@ -17846,8 +17871,12 @@ export struct LocalMusic {
           this.stop();
           this.currentSong = randomSong;
 
+          const randomRemoteListLoading = this.beginRemoteSongSwitchLoading(this.currentSong);
           const randomRemoteListUrl = await this.resolvePlaybackUrlForCurrentSong('randomPlay-remote-list');
           if (!randomRemoteListUrl) {
+            if (randomRemoteListLoading) {
+              this.hideLoadIng();
+            }
             return;
           }
           this.videoUrl = randomRemoteListUrl;
@@ -17916,8 +17945,12 @@ export struct LocalMusic {
           this.CONTROL_PlayStatus = PlayStatus.INIT;
           this.stop();
           this.currentSong = randomRemoteSong;
+          const randomRemoteDbLoading = this.beginRemoteSongSwitchLoading(this.currentSong);
           const randomRemoteUrl = await this.resolvePlaybackUrlForCurrentSong('randomPlay-remote-db');
           if (!randomRemoteUrl) {
+            if (randomRemoteDbLoading) {
+              this.hideLoadIng();
+            }
             return;
           }
           this.videoUrl = randomRemoteUrl;
@@ -18054,8 +18087,12 @@ export struct LocalMusic {
       this.stop();
       this.currentSong = this.songList[this.curIndex];
 
+      const randomFallbackLoading = this.beginRemoteSongSwitchLoading(this.currentSong);
       const randomFallbackUrl = await this.resolvePlaybackUrlForCurrentSong('randomPlay-fallback');
       if (!randomFallbackUrl) {
+        if (randomFallbackLoading) {
+          this.hideLoadIng();
+        }
         return;
       }
       this.videoUrl = randomFallbackUrl;
@@ -18078,8 +18115,12 @@ export struct LocalMusic {
       this.curIndex = index;
       this.currentSong = this.songList[index];
 
+      const playIndexLoading = this.beginRemoteSongSwitchLoading(this.currentSong);
       const playIndexUrl = await this.resolvePlaybackUrlForCurrentSong('playIndex');
       if (!playIndexUrl) {
+        if (playIndexLoading) {
+          this.hideLoadIng();
+        }
         return;
       }
       this.videoUrl = playIndexUrl;
@@ -18092,6 +18133,9 @@ export struct LocalMusic {
         Logger.info('heanup playIndex', '投播模式播放指定歌曲,不调用本地stop()');
         this.initQueueItem();
         await this.prepare();
+        if (playIndexLoading) {
+          this.hideLoadIng();
+        }
         this.cover = this.currentSong.pixelMapPath;
         return;
       }
@@ -18099,6 +18143,9 @@ export struct LocalMusic {
       // 本地播放器模式,需要先stop
       this.CONTROL_PlayStatus = PlayStatus.INIT;
       this.stop();
+      if (playIndexLoading) {
+        this.showLoadIng();
+      }
       this.changeImageAnimation()
     }
 
@@ -18158,8 +18205,12 @@ export struct LocalMusic {
       }
     }
 
+    const previousLoading = this.beginRemoteSongSwitchLoading(this.currentSong);
     const previousUrl = await this.resolvePlaybackUrlForCurrentSong('playPrevious');
     if (!previousUrl) {
+      if (previousLoading) {
+        this.hideLoadIng();
+      }
       return;
     }
     this.videoUrl = previousUrl;
@@ -18181,6 +18232,9 @@ export struct LocalMusic {
         this.updateCastProgress(0);
         await this.castControllerWrapper.playPrevious(this.songList, this.curIndex, this.videoUrl, prevDuration);
         this.isCastPlaying = this.castControllerWrapper.getIsCastPlaying();
+        if (previousLoading) {
+          this.hideLoadIng();
+        }
       } catch (error) {
         Logger.error('heanup playPrevious', `CastController 播放上一首失败: ${error}`);
         this.isCastPlaying = false;
@@ -18192,6 +18246,9 @@ export struct LocalMusic {
     // 本地播放器模式,需要先stop
     this.CONTROL_PlayStatus = PlayStatus.INIT;
     this.stop();
+    if (previousLoading) {
+      this.showLoadIng();
+    }
     this.changeImageAnimation()
   }
 
@@ -18244,8 +18301,12 @@ export struct LocalMusic {
 
       this.currentSong = prevSong;
 
+      const historyLoading = this.beginRemoteSongSwitchLoading(this.currentSong);
       const historyUrl = await this.resolvePlaybackUrlForCurrentSong('randomPlay-history');
       if (!historyUrl) {
+        if (historyLoading) {
+          this.hideLoadIng();
+        }
         return;
       }
       this.videoUrl = historyUrl;