瀏覽代碼

修改mini歌词显示两行

onecold 7 月之前
父節點
當前提交
94204a14bc
共有 2 個文件被更改,包括 27 次插入19 次删除
  1. 13 12
      entry/src/main/ets/view/LocalMusic.ets
  2. 14 7
      lib/src/main/ets/view/LyricView2.ets

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

@@ -9656,6 +9656,7 @@ export struct LocalMusic {
       .setHighlightColor(this.currentHighLightLyricColor)
       .setHighlightColor(this.currentHighLightLyricColor)
       .setHighlightScale(1.2)
       .setHighlightScale(1.2)
       .setEmptyHint("")
       .setEmptyHint("")
+      .setLineSpace(1)
       .setAlignMode('center')
       .setAlignMode('center')
       .setAnimationDuration(500)
       .setAnimationDuration(500)
       .setSingleLine(true)
       .setSingleLine(true)
@@ -10281,7 +10282,7 @@ export struct LocalMusic {
           seekUIStyle: "listItem", // 滑动定位样式(seekLine传统样式,listItem类似抖音汽水音乐样式)
           seekUIStyle: "listItem", // 滑动定位样式(seekLine传统样式,listItem类似抖音汽水音乐样式)
         })
         })
       }
       }
-      .height(66)
+      .height(82)
       .margin({ bottom: 20 })
       .margin({ bottom: 20 })
     }
     }
 
 
@@ -10752,12 +10753,17 @@ export struct LocalMusic {
           // 只有播放网盘歌曲时才显示转圈圈
           // 只有播放网盘歌曲时才显示转圈圈
           if (this.currentSong && isRemoteCloudType(this.currentSong.type)) {
           if (this.currentSong && isRemoteCloudType(this.currentSong.type)) {
             this.showLoadIng();
             this.showLoadIng();
+            setTimeout(() => {
+              let seekValue = value * (this.mIjkMediaPlayer.getDuration() / 100);
+              this.seekTo(seekValue + "");
+            },200)
+          }else{
+            LogUtils.getInstance().LOGI("slider-->seekValue start:" + value);
+            let seekValue = value * (this.mIjkMediaPlayer.getDuration() / 100);
+            this.seekTo(seekValue + "");
+            LogUtils.getInstance().LOGI("slider-->seekValue end:" + seekValue);
           }
           }
-          LogUtils.getInstance().LOGI("slider-->seekValue start:" + value);
-          let seekValue = value * (this.mIjkMediaPlayer.getDuration() / 100);
-          this.seekTo(seekValue + "");
-          // this.setProgress()
-          LogUtils.getInstance().LOGI("slider-->seekValue end:" + seekValue);
+
           // }
           // }
         })
         })
       Text(this.totalTime)
       Text(this.totalTime)
@@ -11261,7 +11267,7 @@ export struct LocalMusic {
 
 
         Column() {
         Column() {
           Row() {
           Row() {
-            Text('单行歌词')
+            Text('显示迷你歌词')
               .margin({ left: 18 })
               .margin({ left: 18 })
               .fontSize(15)
               .fontSize(15)
               .fontColor(Color.White)
               .fontColor(Color.White)
@@ -14446,9 +14452,7 @@ export struct LocalMusic {
   //获取记忆播放功能
   //获取记忆播放功能
   private restorePlaybackPosition() {
   private restorePlaybackPosition() {
     const position: number = PreferencesUtil.getNumberSync(this.videoUrl, 0);
     const position: number = PreferencesUtil.getNumberSync(this.videoUrl, 0);
-    // ToastUtil.showToast('position = ' + position)
     if (this.mIjkMediaPlayer != null && position > 0) {
     if (this.mIjkMediaPlayer != null && position > 0) {
-      // ToastUtil.showToast('seekTo = ' + position)
       this.seekTo(position + "");
       this.seekTo(position + "");
 
 
     }
     }
@@ -14461,9 +14465,6 @@ export struct LocalMusic {
     }
     }
     this.isSeekTo = true
     this.isSeekTo = true
     this.mIjkMediaPlayer.seekTo(value);
     this.mIjkMediaPlayer.seekTo(value);
-    console.info('onecold startPlayOrResumePlay 11227')
-    // this.startPlayOrResumePlay()
-    // 在这里恢复计时器状态
     this.setProgress()
     this.setProgress()
     this.isSeekTo = false
     this.isSeekTo = false
   }
   }

+ 14 - 7
lib/src/main/ets/view/LyricView2.ets

@@ -304,14 +304,14 @@ export struct LyricView2 {
                     curve: Curve.Linear
                     curve: Curve.Linear
                 })
                 })
                 .heightAdaptivePolicy(TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST)
                 .heightAdaptivePolicy(TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST)
-                .padding({ top:5,bottom:5 })
+                .padding(this.isSingleLine?0:{ top:5,bottom:5 })
                 .blendMode(
                 .blendMode(
                     index == this.currentIndex ? BlendMode.DST_IN : undefined,
                     index == this.currentIndex ? BlendMode.DST_IN : undefined,
                     index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
                     index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
                 )
                 )
                 .visibility(this.isSingleLine?
                 .visibility(this.isSingleLine?
-                    (index == this.currentIndex ?Visibility.Visible:Visibility.None)
-                    :Visibility.Visible)
+                    (index >= this.currentIndex && index <= this.currentIndex + 1 ? Visibility.Visible : Visibility.None)
+                    : Visibility.Visible)
                 .width(this.alignMode == 'center' ? '95%' : '85%')
                 .width(this.alignMode == 'center' ? '95%' : '85%')
 
 
             // 中文翻译(整行显示)
             // 中文翻译(整行显示)
@@ -322,12 +322,15 @@ export struct LyricView2 {
                 .fontColor(this.currentMediaPosition >= item.beginTime ?
                 .fontColor(this.currentMediaPosition >= item.beginTime ?
                     index == this.currentIndex ? this.textHighlightColor : this.textColor : this.textColor)
                     index == this.currentIndex ? this.textHighlightColor : this.textColor : this.textColor)
                 .fontWeight(index == this.currentIndex && this.isHighlightBold ? FontWeight.Bold : this.textWeight)
                 .fontWeight(index == this.currentIndex && this.isHighlightBold ? FontWeight.Bold : this.textWeight)
-                .padding({ bottom:5 })
+                .padding(this.isSingleLine?{ bottom:2 }:{ bottom:5 })
                 .textAlign(this.alignMode == 'center' ? TextAlign.Center : TextAlign.Start)
                 .textAlign(this.alignMode == 'center' ? TextAlign.Center : TextAlign.Start)
                 .animation({
                 .animation({
                     duration: 150,
                     duration: 150,
                     curve: Curve.Linear
                     curve: Curve.Linear
                 })
                 })
+                .visibility(this.isSingleLine?
+                    (index >= this.currentIndex && index <= this.currentIndex + 1 ? Visibility.Visible : Visibility.None)
+                    : Visibility.Visible)
                 .blendMode(
                 .blendMode(
                     index == this.currentIndex ? BlendMode.DST_IN : undefined,
                     index == this.currentIndex ? BlendMode.DST_IN : undefined,
                     index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
                     index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
@@ -461,9 +464,9 @@ export struct LyricView2 {
                         .fontWeight(index == this.currentIndex? FontWeight.Bold : this.textWeight)
                         .fontWeight(index == this.currentIndex? FontWeight.Bold : this.textWeight)
                         .margin(isEnglish(word.word) ?{ right:4 }:{})
                         .margin(isEnglish(word.word) ?{ right:4 }:{})
                         .visibility(this.isSingleLine?
                         .visibility(this.isSingleLine?
-                            (index == this.currentIndex ?Visibility.Visible:Visibility.None)
-                            :Visibility.Visible)
-                        .padding({ top:5,bottom:5 })
+                            (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 ?{
                         .shaderStyle(index == this.currentIndex ?{
                             direction: GradientDirection.Right,
                             direction: GradientDirection.Right,
                             colors: this.getWordByWordLyricLyricItemLinearGradient(item, word, index)
                             colors: this.getWordByWordLyricLyricItemLinearGradient(item, word, index)
@@ -490,6 +493,10 @@ export struct LyricView2 {
                             index == this.currentIndex ? this.textHighlightColor : this.textColor : this.textColor)
                             index == this.currentIndex ? this.textHighlightColor : this.textColor : this.textColor)
                         .fontWeight(index == this.currentIndex? FontWeight.Bold : this.textWeight)
                         .fontWeight(index == this.currentIndex? FontWeight.Bold : this.textWeight)
                         .padding({ bottom:5 })
                         .padding({ bottom:5 })
+                        .padding(this.isSingleLine?{ bottom:2 }:{ bottom:5 })
+                        .visibility(this.isSingleLine?
+                            (index >= this.currentIndex && index <= this.currentIndex + 1 ? Visibility.Visible : Visibility.None)
+                            : Visibility.Visible)
                 }
                 }
                 .justifyContent(this.alignMode === 'center' ? FlexAlign.Center : FlexAlign.Start)
                 .justifyContent(this.alignMode === 'center' ? FlexAlign.Center : FlexAlign.Start)
                 .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '85%')
                 .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '85%')