Просмотр исходного кода

修复网盘的RemoteMusicPage 搜索歌曲问题
修复切歌的歌词偶尔有闪现白色条的问题

onecold 5 месяцев назад
Родитель
Сommit
62a94765b0

+ 30 - 2
entry/src/main/ets/view/LocalMusic.ets

@@ -343,6 +343,7 @@ export enum SortMode {
 @Preview
 @Component
 export struct LocalMusic {
+  @State isGeKongPlayNext: boolean = true//是否开启隔空手势播放下一首
   @State bluetoothDisconnectPause: boolean = false // 蓝牙设备断开暂停
   @State isBluetoothConnected: boolean = false // 蓝牙连接状态
   @State bluetoothLyricEnabled: boolean = false // 蓝牙歌词开关
@@ -1236,6 +1237,7 @@ export struct LocalMusic {
     context.getApplicationContext().setColorMode(colorMode)
   }
   initSetting() {
+    this.isGeKongPlayNext  = PreferencesUtil.getBooleanSync('isGeKongPlayNext', false)
     this.bluetoothDisconnectPause = PreferencesUtil.getBooleanSync(SettingPage.BLUETOOTH_DISCONNECT_PAUSE, false)
     this.bluetoothLyricEnabled = PreferencesUtil.getBooleanSync(SettingPage.BLUETOOTH_LYRIC_ENABLED, false)
     this.bluetoothLyricMode = PreferencesUtil.getNumberSync(SettingPage.BLUETOOTH_LYRIC_MODE, 0)
@@ -5856,8 +5858,8 @@ export struct LocalMusic {
             preview: MenuPreviewMode.IMAGE,
             previewAnimationOptions: { scale: [0.8, 1.0] },
           })
-        .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 0.9, y: 0.9 }).animation({ duration: 300 }),
-          TransitionEffect.scale({ x: 0, y: 0 })))
+        // .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 0.9, y: 0.9 }).animation({ duration: 300 }),
+        //   TransitionEffect.scale({ x: 0, y: 0 })))
         .clickEffect({ level: ClickEffectLevel.LIGHT })
         .scale({ x: this.scaleItem === index ? 1.02 : 1, y: this.scaleItem === index ? 1.02 : 1 })
         .zIndex(this.dragItem === index ? 1 : 0)
@@ -9692,6 +9694,9 @@ export struct LocalMusic {
               // 向上滑动:不应用位移动画,保持 translateY = 0
               this.translateY = 0;
             } else {
+              if(this.isGeKongPlayNext){
+                return
+              }
               // 向下滑动:应用位移动画
               this.translateY = offsetY;
 
@@ -9726,6 +9731,11 @@ export struct LocalMusic {
               });
             }
           } else {
+            //这里加个变量,是否开启隔空手势播放下一首
+            if(this.isGeKongPlayNext){
+              this.playNext()
+              return
+            }
             // 向下滑动:关闭播放页
             const shouldClose = this.translateY > minDistance || velocity > minVelocity;
 
@@ -13083,6 +13093,22 @@ export struct LocalMusic {
                   .width(48)
                   .height(24);
 
+                Toggle({ type: ToggleType.Switch, isOn: this.isGeKongPlayNext })
+                .selectedColor(this.themeColor)
+                  .switchPointColor(Color.White)
+                  .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.5 })
+                  .margin({ right: 15 })
+                  .visibility(more.id == 27 ? Visibility.Visible : Visibility.None)
+                  .onChange((checked: boolean) => { // 选择开关状态变化时触发事件
+                    if (more.id == 27) {
+                      this.isGeKongPlayNext = checked;
+                      PreferencesUtil.put('isGeKongPlayNext', this.isGeKongPlayNext)
+                    }
+
+                  })
+                  .width(48)
+                  .height(24);
+
                 Toggle({ type: ToggleType.Switch, isOn: this.isShowBgLiuGUANG })
                   .selectedColor(this.themeColor)
                   .switchPointColor(Color.White)
@@ -13187,6 +13213,8 @@ export struct LocalMusic {
 
     { id : 21, image: $r('app.media.kp_music'), title: '背景双边流光' },
 
+    { id : 27, image: $r('sys.symbol.hand'), title: '隔空手势切歌' },
+
     { id: 8, image: $r('app.media.cut_current'), title: '保存播放模式' },
 
     { id: 7, image: $r('app.media.playlist2'), title: '播放背景随音乐封面' },

+ 1 - 0
entry/src/main/ets/view/RemoteMusicPage.ets

@@ -2809,6 +2809,7 @@ export struct RemoteMusicPage {
         return;
       }
       this.filteredList = videoItems;
+      this.songDataSource.pushArrayData(this.filteredList)
       this.doSortType(this.sortType);
       void ServerLogUtil.info('NavidromeSearch', `搜索完成: "${keyword}"`);
       void ServerLogUtil.info('NavidromeSearch', `- 搜索耗时: ${searchTime}ms`);

+ 5 - 6
lib/src/main/ets/view/LyricView2.ets

@@ -339,7 +339,6 @@ export struct LyricView2 {
             index == this.currentIndex && !(this.currentLyric && this.currentLyric.isPlainText) ? BlendApplyType.OFFSCREEN : undefined
         )
 
-
     }
 
 
@@ -351,7 +350,7 @@ export struct LyricView2 {
         // 只对当前播放行且包含逐字数据的行应用卡拉OK效果
         if (index !== this.currentIndex  || item.words.length === 0) {
             //console.info('heanup', `getLyricItemLinearGradient - 非高亮行或无逐字数据: index=${index}, currentIndex=${this.currentIndex}, hasWords=${item.hasWords()}, wordsCount=${item.words.length}`)
-            return [[Color.White, 0.0], [Color.White, 1.0]]
+            return [[Color.Transparent, 0.0], [Color.Transparent, 1.0]]
         }
 
         // 计算该行歌词的总时长
@@ -458,10 +457,10 @@ export struct LyricView2 {
                             (index >= this.currentIndex && index <= this.currentIndex + 1 ? Visibility.Visible : Visibility.None)
                             : Visibility.Visible)
                         .padding(this.isSingleLine?0:{ top:5,bottom:5 })
-                        // .shaderStyle(index == this.currentIndex ?{
-                        //     direction: GradientDirection.Right,
-                        //     colors: this.getWordByWordLyricLyricItemLinearGradient(item, word, index)
-                        // }:undefined)
+                        .shaderStyle(index == this.currentIndex ?{
+                            direction: GradientDirection.Right,
+                            colors: this.getWordByWordLyricLyricItemLinearGradient(item, word, index)
+                        }:undefined)
                         .animation({
                             duration: 150,
                             curve: Curve.Linear