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

修复跳过尾部 单曲没办法循环
设置增加长歌名可以滚动开关 显示歌曲文件名开关

onecold 10 месяцев назад
Родитель
Сommit
7dc83b2e91

+ 2 - 2
AppScope/app.json5

@@ -2,8 +2,8 @@
   "app": {
     "bundleName": "com.xgplayer.ttmusic.hm",
     "vendor": "example",
-    "versionCode": 20250924,
-    "versionName": "1.6.0",
+    "versionCode": 20250926,
+    "versionName": "1.6.1",
     "icon": "$media:app_icon",
     "label": "$string:app_name",
     "multiAppMode": {

+ 6 - 4
entry/src/main/ets/pages/AboutPage.ets

@@ -14,6 +14,7 @@ import { BusinessError } from '@kit.BasicServicesKit'
 // @Entry
 @Component
 export struct AboutPage{
+  @Consume mType: number
   @Consume isShowDrawer: boolean;
   @Consume offsetX: number;
   @State isDarkMode: boolean = false
@@ -116,15 +117,16 @@ export struct AboutPage{
             .align(Alignment.Center)
           // 左右按钮
           Row() {
-            Image($r('app.media.menu'))
+            Image($r('app.media.left_back_white'))
               .width(26)
               .height(26)
               .margin({ left: 12, right: 8 })
               .onClick(() => {
-                animateTo({ duration: 555 }, () => {
+                this.getUIContext()?.animateTo({ duration: 555 }, () => {
                   // 动画闭包内控制Image组件的出现和消失
-                  this.isShowDrawer = !this.isShowDrawer
-                  this.offsetX = 0
+                  // this.isShowDrawer = !this.isShowDrawer
+                  // this.offsetX = 0
+                  this.mType =0
                 })
               })
             Blank().flexGrow(1)

+ 1 - 0
entry/src/main/ets/pages/ChartsCount.ets

@@ -230,6 +230,7 @@ export struct ChartsCount {
 
         }
         .cachedCount(2)
+        .scrollBar(BarState.Off)
         // .layoutWeight(1)
         // .height('100%')
         .transition(TransitionEffect.asymmetric(

+ 7 - 0
entry/src/main/ets/pages/NewIndex.ets

@@ -147,6 +147,13 @@ struct NewIndex {
       (this.modeType !== 0 && this.isCanBack)) {
       const eventData: emitter.EventData = {};
       emitter.emit({ eventId: 888 }, eventData); // 发送音频广播通知更新doSwipBack
+    }if(this.mType==4||this.mType==5){
+      this.getUIContext()?.animateTo({ duration: 555 }, () => {
+        // 动画闭包内控制Image组件的出现和消失
+        // this.isShowDrawer = !this.isShowDrawer
+        // this.offsetX = 0
+        this.mType =0
+      })
     } else {
       if (this.isShowDrawer) {
         // 如果抽屉菜单打开,先关闭抽屉

+ 71 - 6
entry/src/main/ets/pages/SettingPage.ets

@@ -118,7 +118,8 @@ export struct SettingPage {
   @State isPlayListBgGrass: boolean = true//是否播放列表玻璃透明效果
   @State is_auto_hide_progress: boolean = false
   @State openSkipSongAnimate: boolean = true//切歌动画效果
-
+  @State isShowFileName: boolean = false//切歌动画效果
+  @State isLongNameRoLL: boolean = true//长歌名滚动
 
   @State customizeBgPath: string | undefined = '';
   context = getContext(this);
@@ -227,7 +228,7 @@ export struct SettingPage {
     this.isMemoryLastPlay = PreferencesUtil.getBooleanSync(SettingPage.iS_MEMORY_LAST_PLAY, false)
     this.twoFingerType = PreferencesUtil.getNumberSync(SettingPage.TWO_FINGER_TYPE, 3)
     this.isCircleBtn = PreferencesUtil.getBooleanSync(SettingPage.IS_CIRCLE_BTN, true)
-    this.isCoverTop = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP, false)
+    this.isCoverTop = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP, true)
     this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
     this.isShowAllBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_ALLBAR, true)
     this.isShowPlayPageBack = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_PLAYPAGE_BACK, true)
@@ -243,6 +244,8 @@ export struct SettingPage {
     this.volumeSmall = PreferencesUtil.getBooleanSync('volumeSmall', false)
     this.autoParseMusicName = PreferencesUtil.getBooleanSync('autoParseMusicName', true)
     this.idDefaultMediaKu = PreferencesUtil.getBooleanSync('idDefaultMediaKu', false)
+    this.isShowFileName = PreferencesUtil.getBooleanSync('isShowFileName', false)
+    this.isLongNameRoLL = PreferencesUtil.getBooleanSync('isLongNameRoLL', true)
 
     // 只用 themeMode 控制主题
     this.themeMode = PreferencesUtil.getNumberSync(SettingPage.THEME_MODE, 0)
@@ -542,15 +545,16 @@ export struct SettingPage {
           .align(Alignment.Center)
         // 左侧返回按钮
         Row() {
-          Image($r('app.media.menu'))
+          Image($r('app.media.left_back_white'))
             .width(26)
             .height(26)
             .margin({ left: 12, right: 8 })
             .onClick(() => {
-              animateTo({ duration: 555 }, () => {
+              this.getUIContext()?.animateTo({ duration: 555 }, () => {
                 // 动画闭包内控制Image组件的出现和消失
-                this.isShowDrawer = !this.isShowDrawer
-                this.offsetX = 0
+                // this.isShowDrawer = !this.isShowDrawer
+                // this.offsetX = 0
+                this.mType =0
               })
             })
           Blank().flexGrow(1)
@@ -1236,6 +1240,67 @@ export struct SettingPage {
             }
             .height(55)
             .clickEffect({ level: ClickEffectLevel.HEAVY })
+            Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
+
+            // 列表显示音乐文件名
+            Row() {
+              SymbolGlyph($r('sys.symbol.text_clipboard'))
+                .fontSize(20)
+                .fontColor([this.themeColor])
+                .alignSelf(ItemAlign.Center)
+                .margin({ left: 15 })
+              Text('列表显示音乐文件名')
+                .margin({ left: 8 })
+                .fontSize(15)
+                .fontColor(Color.Gray)
+                .fontWeight(480)
+                .layoutWeight(1)
+              Toggle({ type: ToggleType.Switch, isOn: this.isShowFileName })
+                .selectedColor(this.themeColor)
+                .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+                .switchPointColor(Color.White)
+                .margin({ right: 18 })
+                .onChange((checked: boolean) => {
+                  this.isShowFileName = checked;
+                  PreferencesUtil.put('isShowFileName', this.isShowFileName)
+                  this.sendChangeEvent()
+                })
+                .width(50)
+                .height(30);
+            }
+            .height(55)
+            .clickEffect({ level: ClickEffectLevel.HEAVY })
+
+            Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
+            // 长歌名滚动
+            Row() {
+              SymbolGlyph($r('sys.symbol.close_sidebar'))
+                .fontSize(20)
+                .fontColor([this.themeColor])
+                .alignSelf(ItemAlign.Center)
+                .margin({ left: 15 })
+              Text('长歌名滚动')
+                .margin({ left: 8 })
+                .fontSize(15)
+                .fontColor(Color.Gray)
+                .fontWeight(480)
+                .layoutWeight(1)
+              Toggle({ type: ToggleType.Switch, isOn: this.isLongNameRoLL })
+                .selectedColor(this.themeColor)
+                .clickEffect({level:ClickEffectLevel.LIGHT, scale: 0.5})
+                .switchPointColor(Color.White)
+                .margin({ right: 18 })
+                .onChange((checked: boolean) => {
+                  this.isLongNameRoLL = checked;
+                  PreferencesUtil.put('isLongNameRoLL', this.isLongNameRoLL)
+                  this.sendChangeEvent()
+                })
+                .width(50)
+                .height(30);
+            }
+            .height(55)
+            .clickEffect({ level: ClickEffectLevel.HEAVY })
+
             Line().width('100%').height(0.3).backgroundColor($r('app.color.index_tab_unselected_font_color'))
             // 音量优化
             Row() {

+ 37 - 19
entry/src/main/ets/view/LocalMusic.ets

@@ -654,7 +654,7 @@ export struct LocalMusic {
     this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
     this.isShowAllBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_ALLBAR, true)
     this.twoFingerType = PreferencesUtil.getNumberSync(SettingPage.TWO_FINGER_TYPE, 3)
-    this.isCoverTop = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP, false)
+    this.isCoverTop = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP, true)
     this.isCircleBtn = PreferencesUtil.getBooleanSync(SettingPage.IS_CIRCLE_BTN, true)
     this.isShowPlayPageBack = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_PLAYPAGE_BACK, true)
     this.isCoverTopBig = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_TOP_BIG, false)
@@ -667,8 +667,8 @@ export struct LocalMusic {
     this.openSkipSongAnimate = PreferencesUtil.getBooleanSync(SettingPage.OPEN_SKIPSONG_ANIMATE, true)
     this.volumeSmall = PreferencesUtil.getBooleanSync('volumeSmall', false)
     this.autoParseMusicName = PreferencesUtil.getBooleanSync('autoParseMusicName', true)
-
-
+    this.isShowFileName = PreferencesUtil.getBooleanSync('isShowFileName', false)
+    this.isLongNameRoLL = PreferencesUtil.getBooleanSync('isLongNameRoLL', true)
     if(this.volumeSmall){
       this.volume = 0.5
     }else{
@@ -2604,10 +2604,10 @@ export struct LocalMusic {
 
         Column() {
           Column() {
-            Text(item.name)
+            Text(this.isShowFileName?item.fileName :item.name)
               .fontSize(this.twoFingerType == 1 ? 12 : this.twoFingerType == 2 ? 15 : 18)
               .maxLines(1)
-              .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
+              .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
               .animation({
                 duration: 555,
                 curve: 'Linear',
@@ -2665,19 +2665,22 @@ export struct LocalMusic {
                   .backgroundColor('#FFC107')
               }
               .padding({ top: 8 })
-              Text(StrUtil.isEmpty(item.artist) ? item.cTime : item.artist + '  ' + item?.album)
+              Text(StrUtil.isEmpty(item.artist) ? item.duration : item.artist + '  ' + item?.album)
                 .fontSize(this.twoFingerType == 1 ? 11 : this.twoFingerType == 2 ? 12 : 14)
                 .padding({ top: 8 ,right:25})
+                .visibility(this.isShowFileName?Visibility.None:Visibility.Visible)
                 .maxLines(1)
+                .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
                 .fontColor(this.currentSong?.filePath === item.filePath ? this.themeColor :
                 $r('app.color.text_color'))
                 .margin({ left: this.twoFingerType == 3 ? 6 : 8 })
               Blank()
-              Text(item.size)
+              Text(this.isShowFileName?item.duration:item.size)
                 .fontSize(this.twoFingerType == 1 ? 11 : this.twoFingerType == 2 ? 12 : 14)
                 .padding({ top: 8 })
                 .maxLines(1)
-                .visibility(StrUtil.isEmpty(item.artist) ? Visibility.Visible : Visibility.None)
+                .visibility(this.isShowFileName?Visibility.Visible:StrUtil.isEmpty(item.artist)
+                  ? Visibility.Visible : Visibility.None)
                 .fontColor(this.currentSong?.filePath === item.filePath ? this.themeColor :
                 $r('app.color.text_color'))
                 .margin({ left: 10 })
@@ -3673,7 +3676,7 @@ export struct LocalMusic {
               .fontSize(this.columns == 4 ||this.columns==3? 12 : this.columns == 2 ? 15 : 18)
               .maxLines(1)
               .fontWeight(FontWeight.Bold)
-              .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
+              .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
               .animation({
                 duration: 555,
                 curve: 'Linear',
@@ -3724,7 +3727,7 @@ export struct LocalMusic {
                 Text(StrUtil.isEmpty(item.artist) ? item.duration: item.artist)
                   .fontSize(this.columns == 4 ||this.columns==3? 10 : this.columns == 2 ? 12 : 13)
                   .maxLines(1)
-                  .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
+                  .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
                   .margin({ top: 2})
                   .visibility(item.type == CommonConstants.TYPE_IS_ARTIST
                     || item.type == CommonConstants.TYPE_IS_ALBUM
@@ -4090,11 +4093,11 @@ export struct LocalMusic {
               right: this.currentBreakpoint !== BreakpointTypeEnum.SM ? 40 : 20
             })
           Column() {
-            Text(item.name.startsWith('.') ? item.name.replace(/\./g, '') : item.name)
+            Text(this.isShowFileName?item.fileName :item.name.startsWith('.') ? item.name.replace(/\./g, '') : item.name)
               .fontSize(this.twoFingerType == 1 ? 12 : this.twoFingerType == 2 ? 15 : 18)
               .maxLines(1)
               .fontWeight(FontWeight.Bold)
-              .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
+              .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
               .animation({
                 duration: 555,
                 curve: 'Linear',
@@ -4142,10 +4145,10 @@ export struct LocalMusic {
                 .margin({ top: 2 ,right:6})
                 .visibility((this.modeType == 3 && !this.isCanBack)||(this.modeType == 2 && !this.isCanBack)
                   ||(this.modeType == 0&&item.type==CommonConstants.TYPE_IS_DIR)? Visibility.None : Visibility.Visible)
-                Text(StrUtil.isEmpty(item.artist) ? item.duration: item.artist)
+                Text(this.isShowFileName?item.duration:StrUtil.isEmpty(item.artist) ? item.duration: item.artist)
                   .fontSize(this.twoFingerType == 1 ? 10 : this.twoFingerType == 2 ? 12 : 13)
                   .maxLines(1)
-                  .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
+                  .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
                   .margin({ top: 2})
                   .visibility(item.type == CommonConstants.TYPE_IS_ARTIST
                     || item.type == CommonConstants.TYPE_IS_ALBUM
@@ -7334,9 +7337,9 @@ export struct LocalMusic {
       .margin({ bottom: 8 })
 
     }
-    // .backgroundImage(this.imageLabelBg)
-    .backgroundImage(this.isPuraWP() && this.currentSwiperIndex === 0 ?
-      (StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover) : this.imageLabelBg)
+    .backgroundImage(StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover)
+    // .backgroundImage(this.isPuraWP() && this.currentSwiperIndex === 0 ?
+    //   (StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover) : this.imageLabelBg)
     .backgroundImageSize(this.isPuraWP() ? { width: '100%' } : { height: '150%', width: '100%' })
     // .backgroundImagePosition(Alignment.Center)
     .animation({
@@ -7405,6 +7408,8 @@ export struct LocalMusic {
   @State volume: number = 0.5;
   @State volumeSmall: boolean = false
   @State autoParseMusicName: boolean = true
+  @State isShowFileName: boolean = false
+  @State isLongNameRoLL: boolean = true//长歌名滚动
 
   @State volumeShow: boolean = PlayConstants.VOLUME_SHOW;
   @State bright: number = PlayConstants.BRIGHT;
@@ -7864,7 +7869,6 @@ export struct LocalMusic {
     let bg = Utility.getMusisBg()
     this.imageLabel = bg
 
-
     ColorConversion.setSysBarLightBackground(true);
     this.context.resourceManager.getMediaContent(bg)
       .then((value: Uint8Array) => {
@@ -10881,7 +10885,21 @@ export struct LocalMusic {
       // 判断是否播放到结束时间
       if (this.isOpenJump && duration > this.jumpEndTime * 1000) {
         if (position >= duration - this.jumpEndTime * 1000) {
-          this.playNext()
+          if(this.playType == 1){//跳过尾部如果是单曲循环就选择单曲循环
+            this.CONTROL_PlayStatus = PlayStatus.INIT
+            that.startPlayOrResumePlay();
+          }else if (this.playType == 2) { //2:正常播放,单曲播完
+
+            that.showRePlay();
+            that.currentTime = that.stringForTime(this.mIjkMediaPlayer.getDuration());
+            that.progressValue = this.PROGRESS_MAX_VALUE;
+            that.slideEnable = false;
+            that.stop();
+            // ToastUtil.showToast('开始重新播放')
+          }else{
+            this.playNext()
+          }
+
         }
       }