فهرست منبع

添加批量内嵌标签功能

onecold 11 ماه پیش
والد
کامیت
79e441fa2d
2فایلهای تغییر یافته به همراه116 افزوده شده و 66 حذف شده
  1. 54 16
      entry/src/main/ets/view/LocalMusic.ets
  2. 62 50
      entry/src/main/ets/view/TagsContentCover.ets

+ 54 - 16
entry/src/main/ets/view/LocalMusic.ets

@@ -37,6 +37,7 @@ import { LyricController, LyricParser, LyricView2 } from '@seagazer/cclyric';
 import { AvSessionController } from '../controller/AvSessionController';
 import { repairAudioMetadata,  getApiLyric,changeMusicCover} from '../common/util/MusicTagUtils';
 import { FFMpegTags,Utility } from '../common/util/Utility';
+import { TagsContentCover } from '../view/TagsContentCover';
 import {
   // DeviceChangeReason,
   IjkMediaPlayer,
@@ -204,6 +205,7 @@ export struct LocalMusic {
   @State bgBrightness: number = 0 //背景亮度
   private listScroller: ListScroller = new ListScroller()
   private playListScroller: Scroller = new Scroller()
+  @State isOneKeyTags:boolean = false
   @StorageProp('isLandscape') isLandscape: boolean = false;
   @StorageProp('topRectHeight') topRectHeight: number = px2vp(AppUtil.getStatusBarHeight());
   @StorageProp('windowWidth') windowWidth: number = 0;
@@ -2100,29 +2102,42 @@ export struct LocalMusic {
                 }
                 this.isAllSelected = !this.isAllSelected;
               })
-            Button('剪切', { type: ButtonType.Circle, stateEffect: true })
-              .width('35%')
+
+            Button('内嵌标签', { type: ButtonType.Capsule, stateEffect: true })
+              .width(100)
               .height(60)
-              .id('music_cut')
               .margin({ top: 10, bottom: 10, right: 6 })
               .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
               .backgroundColor(this.themeColor)
-              .onClick(() => {
-                this.showCutDialogForMultipleFiles(false, 'music_cut')
+              .bindContentCover($$this.isOneKeyTags, this.TagsContentCoverBuilder(), {
+                transition: TransitionEffect.translate({ x: 500 }).animation({ curve: curves.springMotion(0.6, 0.8) })
               })
-
-            Button('移动', { type: ButtonType.Circle, stateEffect: true })
-              .width('35%')
-              .height(60)
-              .id('music_cut_current')
-              .visibility(this.isHasDir ? Visibility.Visible : Visibility.None)
-              .margin({ top: 10, bottom: 10, right: 6 })
-              .backgroundColor(this.themeColor)
-              .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
               .onClick(() => {
-
-                this.showCutDialogForMultipleFiles(true, 'music_cut_current')
+                this.isOneKeyTags = !this.isOneKeyTags
               })
+            // Button('剪切', { type: ButtonType.Circle, stateEffect: true })
+            //   .width('35%')
+            //   .height(60)
+            //   .id('music_cut')
+            //   .margin({ top: 10, bottom: 10, right: 6 })
+            //   .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
+            //   .backgroundColor(this.themeColor)
+            //   .onClick(() => {
+            //     this.showCutDialogForMultipleFiles(false, 'music_cut')
+            //   })
+            //
+            // Button('移动', { type: ButtonType.Circle, stateEffect: true })
+            //   .width('35%')
+            //   .height(60)
+            //   .id('music_cut_current')
+            //   .visibility(this.isHasDir ? Visibility.Visible : Visibility.None)
+            //   .margin({ top: 10, bottom: 10, right: 6 })
+            //   .backgroundColor(this.themeColor)
+            //   .clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.5 })
+            //   .onClick(() => {
+            //
+            //     this.showCutDialogForMultipleFiles(true, 'music_cut_current')
+            //   })
             Button('复制', { type: ButtonType.Circle, stateEffect: true })
               .width('35%')
               .height(60)
@@ -2193,6 +2208,29 @@ export struct LocalMusic {
 
   }
 
+  @Builder
+  TagsContentCoverBuilder() {
+    Scroll() {
+      Column() {
+        TagsContentCover(
+          {
+            selectedFiles:this.selectedFiles,
+            isShowDrawer:this.isOneKeyTags,
+            onTagsResult:(result: boolean)=>{
+              this.isMultiSelect = false
+              if(result){//如果嵌入成功,更新数据
+                this.doUpdateData()
+              }
+
+            }
+          }
+        )
+      }
+    }
+    .width('100%')
+    .height('100%')
+  }
+
   asyncCurrentPathData() {
     if (this.modeType == 0) {
       workerInstance.postMessage({

+ 62 - 50
entry/src/main/ets/view/TagsContentCover.ets

@@ -66,7 +66,7 @@ export struct TagsContentCover {
     }
     .height('100%')
     .width('100%')
-    .backgroundColor($r('app.color.start_window_background'))
+    .backgroundColor($r('app.color.index_background'))
   }
 
   @Builder
@@ -74,18 +74,18 @@ export struct TagsContentCover {
     Column(){
       List({ scroller: this.listScroller }) {
         ListItemGroup({ header: this.listHeader() }) {
-        LazyForEach(this.dataSource, (item: VideoItem, index: number) => {
-          ListItem() {
-            Column() {
-              this.MusicItem(item, index)
+          LazyForEach(this.dataSource, (item: VideoItem, index: number) => {
+            ListItem() {
+              Column() {
+                this.MusicItem(item, index)
+              }
             }
-          }
-          .transition(TransitionEffect.asymmetric(
-            TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 500 }),
-            TransitionEffect.scale({ x: 0, y: 0 })
-          ))
-          .clickEffect({ level: ClickEffectLevel.LIGHT })
-        }, (item: VideoItem) => item.filePath)
+            .transition(TransitionEffect.asymmetric(
+              TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 500 }),
+              TransitionEffect.scale({ x: 0, y: 0 })
+            ))
+            .clickEffect({ level: ClickEffectLevel.LIGHT })
+          }, (item: VideoItem) => item.filePath)
         }
 
       }
@@ -101,7 +101,7 @@ export struct TagsContentCover {
     .borderRadius(20)
     .padding({top:10,bottom:6})
     .height('auto')
-    .backgroundColor($r('app.color.index_background'))
+    .backgroundColor($r('app.color.start_window_background'))
     .margin({top:20,right:20,left:20})
     .layoutWeight(1)
     .height('100%')
@@ -178,7 +178,7 @@ export struct TagsContentCover {
 
     }
     .borderRadius(20)
-    .backgroundColor($r('app.color.index_background'))
+    .backgroundColor($r('app.color.start_window_background'))
     .margin({top:20,right:20,left:20})
   }
 
@@ -216,7 +216,7 @@ export struct TagsContentCover {
       .margin({top:20,right:20,left:20})
       .height(55)
       .enabled(!this.isEmbedding)
-      .backgroundColor(Color.Transparent)
+      .backgroundColor($r('app.color.start_window_background'))
       .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
       .onClick(()=>{
         this.startEmbed()
@@ -235,6 +235,18 @@ export struct TagsContentCover {
       return;
     }
 
+    if (this.isCover&&PreferencesUtil.getStringSync('COVER_API',  '') === '') {
+      ToastUtil.showToast('请到设置界面配置封面Api')
+      return; // Return empty string when no API is configured
+    }
+
+    //判断有没有设置api
+    let apiUrl = PreferencesUtil.getStringSync('LRC_API', '')
+    if (this.isLyric&&StrUtil.isEmpty(apiUrl)) {
+      ToastUtil.showToast('请到设置界面配置歌词Api')
+      return
+    }
+
     this.isEmbedding = true;
     this.currentProgress = 0;
     this.currentFileIndex = 0;
@@ -435,43 +447,43 @@ export struct TagsContentCover {
   @Builder
   private MusicItem(item: VideoItem, index?: number) {
     Button({ type: ButtonType.Normal, stateEffect: true }) {
-        Column() {
-          Row() {
-            SymbolGlyph($r('sys.symbol.music'))
-              .fontSize(20)
-              .fontColor([this.themeColor])
-              .alignSelf(ItemAlign.Center)
-              .padding({ left: 25 })
-            Text(item.name)
-              .fontSize(14)
-              .maxLines(1)
-              .padding({ left: 5 })
-              .textOverflow({ overflow: TextOverflow.MARQUEE })
-              .animation({
-                duration: 555,
-                curve: 'Linear',
-              })
-              .fontColor(Color.Gray)
-              .margin({ left: 8 })
-            Blank()
-            // 根据嵌入状态显示勾选图标
-            SymbolGlyph($r('sys.symbol.checkmark_circle'))
-              .fontSize(20)
-              .fontColor([this.themeColor])
-              .alignSelf(ItemAlign.Center)
-              .padding({ right: 25 })
-              .animation({
-                duration: 666,
-                curve: 'ease-in-out' // 可选动画曲线
-              })
-              .visibility(this.embedStatusMap.get(item.filePath)?Visibility.Visible:Visibility.None)
-
-          }
-          .layoutWeight(1)
-          .height('100%')
-          .width('100%')
+      Column() {
+        Row() {
+          SymbolGlyph($r('sys.symbol.music'))
+            .fontSize(20)
+            .fontColor([this.themeColor])
+            .alignSelf(ItemAlign.Center)
+            .padding({ left: 25 })
+          Text(item.name)
+            .fontSize(14)
+            .maxLines(1)
+            .padding({ left: 5 })
+            .textOverflow({ overflow: TextOverflow.MARQUEE })
+            .animation({
+              duration: 555,
+              curve: 'Linear',
+            })
+            .fontColor(Color.Gray)
+            .margin({ left: 8 })
+          Blank()
+          // 根据嵌入状态显示勾选图标
+          SymbolGlyph($r('sys.symbol.checkmark_circle'))
+            .fontSize(20)
+            .fontColor([this.themeColor])
+            .alignSelf(ItemAlign.Center)
+            .padding({ right: 25 })
+            .animation({
+              duration: 666,
+              curve: 'ease-in-out' // 可选动画曲线
+            })
+            .visibility(this.embedStatusMap.get(item.filePath)?Visibility.Visible:Visibility.None)
 
         }
+        .layoutWeight(1)
+        .height('100%')
+        .width('100%')
+
+      }
     }
     .backgroundColor(Color.Transparent)
     .width('100%')