chendeben 1 rok temu
rodzic
commit
44ec489ebe

+ 19 - 65
entry/src/main/ets/common/util/MediaTable.ets

@@ -31,16 +31,6 @@ interface DBColumnsInterface {
   LYRIC_CONTENT: string;
 }
 
-/**
- * 媒体元数据接口定义
- */
-export interface MediaMetadata {
-  duration?: string;
-  mimeType?: string;
-  sampleRate?: string;
-  trackCount?: string;
-}
-
 /**
  * 数据库字段常量,避免硬编码
  */
@@ -289,12 +279,15 @@ export default class MediaTable {
         console.log(`${RdbUtils.RDB_TAG}` + 'Query no results!');
         callback([]);
       } else {
+
+
         const result = this.parseResultSetToVideoItems(resultSet);
         callback(result);
       }
     });
   }
 
+
   // 新增方法:根据parentPath查询数据
   public queryByParentPath(path: string, callback: (result: VideoItem[]) => void) {
     try {
@@ -307,12 +300,14 @@ export default class MediaTable {
         const result = this.parseResultSetToVideoItems(resultSet);
         callback(result);
       });
-    } catch (err) {
-      Logger.error(`查询parentPath失败: ${err.message}`);
-      callback([]);
+    }catch (err) {
+      Logger.error(` onecold testtag queryByParentPath: ${err.code}  - ${err.message}`);
+
     }
+    // 1. 构建查询条件
+
   }
-  
+
   // 查询所有艺术家及其歌曲(返回Map结构:artist -> VideoItem[])
   public queryArtistsWithSongs(callback: (result: Map<string, VideoItem[]>) => void) {
     // 1. 查询去重的艺术家列表(非空)
@@ -346,6 +341,9 @@ export default class MediaTable {
     });
   }
 
+
+
+
   // 查询所有专辑及其歌曲(返回Map结构:album -> VideoItem[])
   public queryAlbumsWithSongs(callback: (result: Map<string, VideoItem[]>) => void) {
     // 1. 查询去重的专辑列表(非空)
@@ -379,6 +377,8 @@ export default class MediaTable {
     });
   }
 
+
+
   // 解析去重列数据(如artist/album)
   private parseDistinctColumn(resultSet: relationalStore.ResultSet, columnName: string): string[] {
     const uniqueValues = new Set<string>();  // 使用Set特性自动去重
@@ -398,7 +398,7 @@ export default class MediaTable {
     return Array.from(uniqueValues);   // Set转数组
   }
 
-  // 将ResultSet解析为VideoItem数组
+  // 将ResultSet解析为VideoItem数组(复用原有逻辑)
   private parseResultSetToVideoItems(resultSet: relationalStore.ResultSet): VideoItem[] {
     const items: VideoItem[] = [];
 
@@ -462,58 +462,8 @@ export default class MediaTable {
     return item;
   }
 
-  // 根据文件路径查询数据
-  public queryByFilePath(filePath: string, callback: (result: VideoItem[]) => void) {
-    try {
-      const predicates = new relationalStore.RdbPredicates(RdbUtils.MEDIA_TABLE.tableName);
-      predicates.equalTo('filePath', filePath);
 
-      // 执行查询并处理结果
-      this.accountTable.query(predicates, (resultSet: relationalStore.ResultSet) => {
-        // 复用已有的解析逻辑
-        const result = this.parseResultSetToVideoItems(resultSet);
-        callback(result);
-      });
-    } catch (err) {
-      Logger.error(`查询文件路径失败 - filePath: ${filePath}, error: ${err.code} - ${err.message}`);
-      callback([]);
-    }
-  }
 
-  // 更新媒体文件的元数据信息(采样率、MIME类型等)
-  public updateMediaMetadata(filePath: string, metadata: MediaMetadata, callback: (success: boolean) => void) {
-    try {
-      // 构建查询条件
-      const predicates = new relationalStore.RdbPredicates(RdbUtils.MEDIA_TABLE.tableName);
-      predicates.equalTo('filePath', filePath);
-      
-      // 构建更新值
-      const valuesToUpdate: relationalStore.ValuesBucket = {};
-      if (metadata.duration) {
-        valuesToUpdate.duration = metadata.duration;
-      }
-      if (metadata.mimeType) {
-        valuesToUpdate.mimeType = metadata.mimeType;
-      }
-      if (metadata.sampleRate) {
-        valuesToUpdate.sampleRate = metadata.sampleRate;
-      }
-      if (metadata.trackCount) {
-        valuesToUpdate.trackCount = metadata.trackCount;
-      }
-      
-      // 执行更新
-      if (Object.keys(valuesToUpdate).length > 0) {
-        this.accountTable.updateData(predicates, valuesToUpdate, callback);
-      } else {
-        Logger.info('No metadata to update');
-        callback(false);
-      }
-    } catch (err) {
-      Logger.error(`更新媒体元数据失败: ${err.message}`);
-      callback(false);
-    }
-  }
 }
 
 function generateBucket(item: VideoItem): relationalStore.ValuesBucket {
@@ -527,6 +477,9 @@ function generateBucket(item: VideoItem): relationalStore.ValuesBucket {
   obj.parentPath = item.parentPath;
   obj.isFav = item.isFav;
 
+  // if(item.pixelMapToString){
+  //   obj.pixelMapToString = item.pixelMapToString;
+  // }
   if(item.artist){
     obj.artist = item.artist;
   }
@@ -543,6 +496,7 @@ function generateBucket(item: VideoItem): relationalStore.ValuesBucket {
     obj.pixelMapPath = item.pixelMapPath;
   }
 
+
   if(item.duration){
     obj.duration = item.duration;
   }

+ 4 - 38
entry/src/main/ets/common/util/Utility.ets

@@ -125,45 +125,11 @@ export class Utility {
   }
 
   static convertToKHz(sampleRateHz: string|undefined): string {
-    if(StrUtil.isEmpty(sampleRateHz) || sampleRateHz === undefined || sampleRateHz === "0") {
-      return '未知';
-    }
-
-    try {
-      const sampleRateNum = Number(sampleRateHz);
-      if (isNaN(sampleRateNum) || sampleRateNum <= 0) {
-        return '未知';
-      }
-      const sampleRateKHz = sampleRateNum / 1000;
-      return `${sampleRateKHz.toFixed(1)} KHz`;
-    } catch (err) {
-      console.error(`转换采样率出错: ${err}`);
-      return '未知';
-    }
-  }
+    if(StrUtil.isEmpty(sampleRateHz)||sampleRateHz ===undefined)
+      return '0KHz'
 
-  /**
-   * 格式化媒体格式类型显示
-   * @param mimeType 媒体格式类型字符串
-   * @return 格式化后的显示字符串
-   */
-  static formatMimeType(mimeType: string|undefined): string {
-    if(StrUtil.isEmpty(mimeType) || mimeType === undefined) {
-      return '未知';
-    }
-    
-    // 从MIME类型中提取格式部分,例如 "audio/mp3" -> "MP3"
-    try {
-      const parts = mimeType.split('/');
-      if (parts.length > 1) {
-        return parts[1].toUpperCase();
-      } else {
-        return mimeType.toUpperCase();
-      }
-    } catch (err) {
-      console.error(`格式化媒体类型出错: ${err}`);
-      return '未知';
-    }
+    const sampleRateKHz = Number(sampleRateHz) / 1000;
+    return `${sampleRateKHz} KHz`;
   }
 
   /**

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

@@ -85,8 +85,8 @@ import { deviceInfo } from '@kit.BasicServicesKit';
 import { HSBColorPicker, HSBColorPickerLayout } from '@keke/color-picker'
 import { DEBUG } from 'BuildProfile';
 import { LrcParser } from '@sgaolei/lrc_parser';
+import { IBestIcon } from "@ibestservices/ibest-ui";
 import app, { AppResponse } from '@system.app';
-import { Log } from '@tencent/wechat_open_sdk';
 
 const TAG = 'LocalMusic';
 
@@ -768,6 +768,7 @@ export struct LocalMusic {
         files = result;
       }
 
+
       files.sort((a, b) => a.cTime.localeCompare(b.cTime));
       Utility.doSortListAscending(files)
 
@@ -795,7 +796,7 @@ export struct LocalMusic {
       console.info(`onecold gengxin 1: ${this.videoLocalList.length}`);
       // for (let i = 0; i < this.videoLocalList.length; i++) {
       //
-      //   console.info(`onecold gengxin 1: ${this.videoLocalList[i].sampleRate}`);
+      //   console.info(`onecold gengxin 1: ${this.videoLocalList[i].pixelMapPath}`);
       //
       // }
 
@@ -2159,11 +2160,14 @@ export struct LocalMusic {
   @Builder
   private DirItem(item: VideoItem, index?: number) {
     Row() {
-      Image(this.modeType !== 0 && StrUtil.isNotEmpty(item.pixelMapPath) ? item.pixelMapPath :
-      $r('app.media.music_group'))
+      // Image(this.modeType !== 0 && StrUtil.isNotEmpty(item.pixelMapPath) ? item.pixelMapPath :
+      // $r('app.media.music_group'))
+      SymbolGlyph($r('sys.symbol.identify_song'))
         .height(33)
         .width(33)
-        .alt($r('app.media.music_group'))
+        .fontColor([$r('app.color.img_color')])
+        .fontSize(33)
+        // .alt($r('app.media.music_group'))
         .borderRadius('100%')
         .clip(true)
         .margin({ left: 20, top: 8, bottom: 8 })
@@ -2475,6 +2479,7 @@ export struct LocalMusic {
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })// .opacity(this.opacityItem)
+          .fillColor($r('app.color.img_color'))
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.isSearchMode = true
@@ -2490,12 +2495,14 @@ export struct LocalMusic {
             this.showRankDialog()
           })
 
-        Image(this.isGridMusic?$r('app.media.list'):$r("app.media.grid"))
+        SymbolGlyph(this.isGridMusic?$r('sys.symbol.list_bullet'):$r('sys.symbol.square_grid_2x2'))
+        .fontColor([$r('app.color.img_color')])
           .width(25)
           .animation({
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })
+
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.isGridMusic = !this.isGridMusic
@@ -2514,10 +2521,11 @@ export struct LocalMusic {
 
       Row({ space: 8 }) {
         Row({ space: 8 }) {
-          Image($r("app.media.hm_play"))
+          // Image($r("app.media.hm_play"))
+          IBestIcon({name:'play-circle-o',iconSize:25,color:$r('app.color.img_color')})
             .width(25)
             .margin({ left: 8 })
-            .fillColor('#ff5186')
+            // .fillColor($r('app.color.img_color'))
           Text(`播放全部`)
             .fontColor($r('app.color.text_color'))
             .fontSize(14)
@@ -2593,6 +2601,7 @@ export struct LocalMusic {
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })// .opacity(this.opacityItem)
+          .fillColor($r('app.color.img_color'))
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.isSearchMode = true
@@ -2603,17 +2612,20 @@ export struct LocalMusic {
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })
+          .fillColor($r('app.color.img_color'))
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.isGridMusic = !this.isGridMusic
           })
-        Image($r("app.media.refresh"))
-          .width(25)
+        // Image($r("app.media.refresh"))
+        IBestIcon({ name: 'replay',iconSize:25,color:$r('app.color.img_color') })
+          // .width(25)
           .visibility(this.isHistory || this.isCanBack || this.isSearchMode ? Visibility.None : Visibility.Visible)
           .animation({
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })// .opacity(this.opacityItem)
+          // .fillColor($r('app.color.img_color'))
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             if(this.isFavMusic){
@@ -2632,6 +2644,7 @@ export struct LocalMusic {
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })
+          .fillColor($r('app.color.img_color'))
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.showRankDialog()
@@ -2641,12 +2654,13 @@ export struct LocalMusic {
         Image(this.isMultiSelect ? $r("app.media.cancel_multi") : $r("app.media.top_flower"))
           .width(24)
           .margin({ right: 10 })
-          .fillColor('#ff5186')// .opacity(this.opacityItem)
+          // .fillColor('#ff5186')// .opacity(this.opacityItem)
           .visibility(this.isHistory || this.isSearchMode ? Visibility.None : Visibility.Visible)
           .animation({
             duration: 666,
             curve: 'ease-in-out' // 可选动画曲线
           })
+          .fillColor($r('app.color.img_color'))
           .clickEffect({ level: ClickEffectLevel.MIDDLE })
           .onClick(() => {
             this.isMultiSelect = !this.isMultiSelect
@@ -2654,7 +2668,7 @@ export struct LocalMusic {
         Image($r("app.media.uninstall_green"))
           .width(24)
           .margin({ right: 10 })
-          .fillColor('#ff5186')
+          .fillColor($r('app.color.img_color'))
           .visibility(this.isHistory ? Visibility.Visible : Visibility.None)
           .animation({
             duration: 666,
@@ -3599,6 +3613,7 @@ export struct LocalMusic {
             .height(24)
             .width(24)
             .margin({ left: 8, right: 16 })
+            .fillColor($r('app.color.img_color'))
             .displayPriority(2)
             .onClick(() => {
               if (ArrayUtil.isNotEmpty(this.songList)) {
@@ -3624,6 +3639,7 @@ export struct LocalMusic {
               .height(32)
               .width(32)
               .displayPriority(3)
+              .fillColor($r('app.color.img_color'))
               .onClick(() => {
                 if (ArrayUtil.isNotEmpty(this.songList)) {
                   this.playOrPause()
@@ -3641,6 +3657,7 @@ export struct LocalMusic {
               right: 16,
               left: 16
             })
+            .fillColor($r('app.color.img_color'))
             .displayPriority(2)
             .onClick(() => {
               if (ArrayUtil.isNotEmpty(this.songList)) {
@@ -3655,6 +3672,7 @@ export struct LocalMusic {
             .height(24)
             .width(24)
             .displayPriority(1)
+            .fillColor($r('app.color.img_color'))
             .bindSheet($$this.isShowSheet, this.PlayListSheet(), {
               height: '95%',
               dragBar: true,
@@ -8919,8 +8937,10 @@ function cutPopupBuilder(dataBu: BubbleBean) {
         ListItem() {
           Row() {
             Column() {
-              Image($r('app.media.music_group'))
+              // Image($r('app.media.music_group'))
+              SymbolGlyph($r('sys.symbol.identify_song'))
                 .height(28)
+                .fontColor([$r('app.color.img_color')])
                 .alignSelf(ItemAlign.Center)
 
             }

+ 28 - 0
oh-package-lock.json5

@@ -9,6 +9,8 @@
     "@cashier_alipay/cashiersdk@^15.8.32": "@cashier_alipay/cashiersdk@15.8.32",
     "@changwei/chardet@^1.0.0": "@changwei/chardet@1.0.0",
     "@chinalike/popup@^0.0.7": "@chinalike/popup@0.0.7",
+    "@hview/dayjs@^1.11.11": "@hview/dayjs@1.11.11",
+    "@ibestservices/ibest-ui@^2.1.2": "@ibestservices/ibest-ui@2.1.2",
     "@keke/color-picker@^1.0.4": "@keke/color-picker@1.0.4",
     "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0",
     "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19",
@@ -25,6 +27,7 @@
     "class-transformer@^0.5.1": "class-transformer@0.5.1",
     "libblueshield.so@oh_modules/.ohpm/@alipay+blueshieldsdk@cow+0gass5tzqhymzjby2f6sd+g2xtoatqsiyvi9qsy=/oh_modules/@alipay/blueshieldsdk/src/main/cpp/types/libblueshield": "libblueshield.so@oh_modules/.ohpm/@alipay+blueshieldsdk@cow+0gass5tzqhymzjby2f6sd+g2xtoatqsiyvi9qsy=/oh_modules/@alipay/blueshieldsdk/src/main/cpp/types/libblueshield",
     "liblrcparser.so@oh_modules/.ohpm/@sgaolei+lrc_parser@1.0.0/oh_modules/@sgaolei/lrc_parser/src/main/cpp/types/liblrcparser": "liblrcparser.so@oh_modules/.ohpm/@sgaolei+lrc_parser@1.0.0/oh_modules/@sgaolei/lrc_parser/src/main/cpp/types/liblrcparser",
+    "lunar@^1.0.0": "lunar@1.0.0",
     "pako@^2.1.0": "pako@2.1.0"
   },
   "packages": {
@@ -63,6 +66,24 @@
       "resolved": "https://repo.harmonyos.com/ohpm/@chinalike/popup/-/popup-0.0.7.har",
       "registryType": "ohpm"
     },
+    "@hview/dayjs@1.11.11": {
+      "name": "@hview/dayjs",
+      "version": "1.11.11",
+      "integrity": "sha512-JPJlAbcCS8STHIRnesbAPWCF6eAlIkGx5rDPGT8CesSCMsB6ZJWEH+l3hl0YqtmfofCCVpWrzjBG7Z2f18olAw==",
+      "resolved": "https://ohpm.openharmony.cn/ohpm/@hview/dayjs/-/dayjs-1.11.11.har",
+      "registryType": "ohpm"
+    },
+    "@ibestservices/ibest-ui@2.1.2": {
+      "name": "@ibestservices/ibest-ui",
+      "version": "2.1.2",
+      "integrity": "sha512-uKRdQIZ3K7M5gSnKnYy8aTzhKszTOVLXG1PINma2kpFgACLfeQdqWdN8MtoOnYX0ldng9s0fe+wtdF9reACb6A==",
+      "resolved": "https://ohpm.openharmony.cn/ohpm/@ibestservices/ibest-ui/-/ibest-ui-2.1.2.har",
+      "registryType": "ohpm",
+      "dependencies": {
+        "@hview/dayjs": "^1.11.11",
+        "lunar": "^1.0.0"
+      }
+    },
     "@keke/color-picker@1.0.4": {
       "name": "@keke/color-picker",
       "version": "1.0.4",
@@ -181,6 +202,13 @@
       "resolved": "oh_modules/.ohpm/@sgaolei+lrc_parser@1.0.0/oh_modules/@sgaolei/lrc_parser/src/main/cpp/types/liblrcparser",
       "registryType": "local"
     },
+    "lunar@1.0.0": {
+      "name": "lunar",
+      "version": "1.0.0",
+      "integrity": "sha512-sAMOxbVr7Sn/QEzEQZHz0CwYjOROTgDLc4842CX2d7f+1D2nlHc6T5jtZJoleIMPZItNJLj0GuOaB/JR+Iwe7Q==",
+      "resolved": "https://ohpm.openharmony.cn/ohpm/lunar/-/lunar-1.0.0.har",
+      "registryType": "ohpm"
+    },
     "pako@2.1.0": {
       "name": "pako",
       "version": "2.1.0",