Kaynağa Gözat

数据库增加位深 声道 声道布局 起始播放点等字段,详情可以展示

onecold 1 yıl önce
ebeveyn
işleme
5fa7f1f846

+ 23 - 0
entry/src/main/ets/common/util/MediaTable.ets

@@ -241,6 +241,11 @@ export default class MediaTable {
       obj.genre  = resultSet.getString(resultSet.getColumnIndex('genre'));
       obj.track  = resultSet.getString(resultSet.getColumnIndex('track'));
 
+      obj.bits_per_raw_sample  = resultSet.getString(resultSet.getColumnIndex('bits_per_raw_sample'));
+      obj.channels  = resultSet.getString(resultSet.getColumnIndex('channels'));
+      obj.channel_layout  = resultSet.getString(resultSet.getColumnIndex('channel_layout'));
+      obj.start_time  = resultSet.getString(resultSet.getColumnIndex('start_time'));
+
       const valueBucket: relationalStore.ValuesBucket = obj
       // Step 4: 执行更新
       const updatePredicates = new relationalStore.RdbPredicates(RdbUtils.MEDIA_TABLE.tableName);
@@ -567,6 +572,11 @@ export default class MediaTable {
     item.genre = safeGet('genre');
     item.track = safeGet('track');
 
+    item.bits_per_raw_sample = safeGet('bits_per_raw_sample');
+    item.channels = safeGet('channels');
+    item.channel_layout = safeGet('channel_layout');
+    item.start_time = safeGet('start_time');
+
     return item;
   }
 
@@ -661,5 +671,18 @@ function generateBucket(item: VideoItem): relationalStore.ValuesBucket {
     obj.track = item.track;
   }
 
+  if(item.bits_per_raw_sample){
+    obj.bits_per_raw_sample = item.bits_per_raw_sample;
+  }
+  if(item.channels){
+    obj.channels = item.channels;
+  }
+  if(item.channel_layout){
+    obj.channel_layout = item.channel_layout;
+  }
+  if(item.start_time){
+    obj.start_time = item.start_time;
+  }
+
   return obj;
 }

+ 12 - 1
entry/src/main/ets/common/util/RdbUtils.ets

@@ -70,12 +70,18 @@ export default class RdbUtils {
       '        genre TEXT,\n' +
       '        track TEXT,\n' +
 
+      '        bits_per_raw_sample TEXT,\n' +
+      '        channels TEXT,\n' +
+      '        channel_layout TEXT,\n' +
+      '        start_time TEXT,\n' +
+
       '        mimeType TEXT' +
       ')',
     columns: ['id', 'name', 'filePath','mtype', 'videoSize', 'cTime','size', 'artist', 'album',
       'fileName','parentPath','isFav','pixelMapPath','pixelMapToString',
       'duration',   'sampleRate','playCount',  'lastPlayedStr', 'trackCount',
-      'lyricContent','md5Str','extra_json','pyStr','bit_rate','probe_score','year','nb_streams','nb_programs','genre','track','mimeType']
+      'lyricContent','md5Str','extra_json','pyStr','bit_rate','probe_score','year','nb_streams','nb_programs',
+      'genre','track',  'bits_per_raw_sample','channels',  'channel_layout','start_time',  'mimeType']
   };
 
   constructor(tableName: string, sqlCreateTable: string, columns: Array<string>) {
@@ -158,6 +164,11 @@ export default class RdbUtils {
             'genre': 'TEXT',
             'track': 'TEXT',
 
+            'bits_per_raw_sample': 'TEXT',
+            'channels': 'TEXT',
+            'channel_layout': 'TEXT',
+            'start_time': 'TEXT',
+
           };
           
           // 逐个添加列,不依赖于检查结果

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

@@ -66,6 +66,12 @@ interface FFprobeStream {
   sample_rate?: string; // 采样率
   bit_rate?: string;    // 比特率
   disposition?: StreamDisposition;  // 添加disposition属性
+
+  bits_per_raw_sample?: string;  // 位深
+  channels?: string; // 声道数
+  channel_layout?: string;    // 声道布局
+  start_time?: string;  // 起始播放
+
 }
 
 interface StreamDisposition {
@@ -811,22 +817,29 @@ export class Utility {
         },
       }).then(async () => {
         try {
-          let videoItem:VideoItem = new VideoItem('',inputPath,inputPath,type,0,'')
           const metadata: FFprobeMetadata = JSON.parse(outputJson);
           const format = metadata.format;
           console.log(`onecold outputJson:${outputJson}`);
           let file = fs.openSync(inputPath, fs.OpenMode.READ_ONLY | fs.OpenMode.CREATE)
           console.info('readMetaInfoFFmpeg asset file.path: ', file.path);
-          videoItem = new VideoItem(file.name,inputPath,inputPath,type,0,'')
+          let videoItem = new VideoItem(file.name,inputPath,inputPath,type,0,'')
           await fs.stat(file.fd).then(async (stat: fs.Stat) => {
 
             // 获取音频流的采样率
-            let sampleRate = '';
+            let sampleRate:string|undefined = '';
+            let bits_per_raw_sample:string|undefined = '';
+            let channels:string|undefined = '';
+            let channel_layout:string|undefined = '';
+            let start_time:string|undefined = '';
             if (metadata.streams  && metadata.streams.length  > 0) {
               // 查找第一个音频流
               const audioStream = metadata.streams.find(stream  => StrUtil.isNotEmpty(stream.sample_rate));
-              if (audioStream&&audioStream.sample_rate)  {
+              if (audioStream)  {
                 sampleRate = audioStream.sample_rate;
+                bits_per_raw_sample = audioStream.bits_per_raw_sample
+                channel_layout = audioStream.channel_layout
+                channels = audioStream.channels
+                start_time = audioStream.start_time
               }
             }
 
@@ -889,6 +902,12 @@ export class Utility {
             videoItem.lyricContent  = tags.LYRICS || tags.lyrics  ||  tags.USLT || tags.UNSYNCEDLYRICS || '';
             videoItem.genre  = tags.genre||tags.GENRE|| Utility.resourceToString(context, $r('app.string.unknown'));
             videoItem.track  = tags.track||tags.TRACK|| Utility.resourceToString(context, $r('app.string.unknown'));
+
+            videoItem.bits_per_raw_sample = bits_per_raw_sample ||'1'
+            videoItem.channel_layout = channel_layout || ''
+            videoItem.channels = channels ||'0'
+            videoItem.start_time = start_time || '00:00'
+
             videoItem.mimeType = format.format_name
             // 检查是否有封面图片流
             const hasCover = metadata.streams.some(stream  =>

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

@@ -560,6 +560,7 @@ export struct UserCenter {
                 PreferencesUtil.putSync('subscriptionEndDate', '');
                 PreferencesUtil.putSync('hasActiveSubscription', false);
                 PreferencesUtil.putSync('userToken', '');
+                PreferencesUtil.putSync('isForever', false);
                 emitter.emit({ eventId: 1001 }, {})
                 ToastUtil.showToast('已退出登录')
               })

+ 69 - 21
entry/src/main/ets/view/LocalMusic.ets

@@ -5117,37 +5117,25 @@ export struct LocalMusic {
             Image(StrUtil.isEmpty(currentItem.pixelMapPath) ? $r('app.media.music_red') :
             currentItem.pixelMapPath)
               .fillColor(this.themeColor)
-              .height(33)
-              .width(33)
-              .borderRadius('100%')
-              .clip(true)
+              .height(80)
+              .width(80)
+              .borderRadius(10)
               .opacity(this.opacityItem)// 绑定透明度
-              .margin({ left: 20 })
+              .margin({ left: 22 })
           }
-          .width('15%')
+
 
           Column() {
             Column() {
               Text(currentItem.name)
-                .fontSize(14)
+                .fontSize(16)
                 .maxLines(1)
                 .animation({
                   duration: 555,
                   curve: 'Linear',
                 })
-
                 .fontColor($r('app.color.text_color'))
-                .margin({ left: 10 })
-              Row() {
-                Text(StrUtil.isEmpty(currentItem.artist) ? currentItem.cTime :
-                  currentItem.artist + '  ' + currentItem?.album)
-                  .fontSize(11)
-                  .padding({ top: 8 })
-                  .fontColor($r('app.color.text_color'))
-                  .margin({ left: 10 })
-
-              }
-
+                .margin({ left: 15 })
             }
             .height('100%')
             .width('100%')
@@ -5159,12 +5147,12 @@ export struct LocalMusic {
 
         }
         .width('100%')
-        .height(58)
+        .height(90)
 
         .justifyContent(FlexAlign.SpaceBetween)
 
         Row() {
-          Text('歌手名:')
+          Text('艺术家:')
             .fontSize(14)
             .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
@@ -5241,6 +5229,66 @@ export struct LocalMusic {
         .margin({ top: 10, bottom: 10 })
         .justifyContent(FlexAlign.Start)
 
+        Row() {
+          Text('位深:')
+            .fontSize(14)
+            .fontColor($r('app.color.text_color'))
+            .margin({ left: 22 })
+          Text(`${currentItem.bits_per_raw_sample} bits`)
+            .fontSize(14)
+            .margin({ left: 10 })
+            .fontColor($r('app.color.text_color'))
+            .layoutWeight(1)
+        }
+        .width('100%')
+        .margin({ top: 10, bottom: 10 })
+        .justifyContent(FlexAlign.Start)
+
+        Row() {
+          Text('声道:')
+            .fontSize(14)
+            .fontColor($r('app.color.text_color'))
+            .margin({ left: 22 })
+          Text(`${currentItem.channels}`)
+            .fontSize(14)
+            .margin({ left: 10 })
+            .fontColor($r('app.color.text_color'))
+            .layoutWeight(1)
+        }
+        .width('100%')
+        .margin({ top: 10, bottom: 10 })
+        .justifyContent(FlexAlign.Start)
+
+        Row() {
+          Text('声道布局:')
+            .fontSize(14)
+            .fontColor($r('app.color.text_color'))
+            .margin({ left: 22 })
+          Text(`${currentItem.channel_layout}`)
+            .fontSize(14)
+            .margin({ left: 10 })
+            .fontColor($r('app.color.text_color'))
+            .layoutWeight(1)
+        }
+        .width('100%')
+        .margin({ top: 10, bottom: 10 })
+        .justifyContent(FlexAlign.Start)
+
+        Row() {
+          Text('起始播放点:')
+            .fontSize(14)
+            .fontColor($r('app.color.text_color'))
+            .margin({ left: 22 })
+          Text(`${currentItem.start_time}`)
+            .fontSize(14)
+            .margin({ left: 10 })
+            .fontColor($r('app.color.text_color'))
+            .layoutWeight(1)
+        }
+        .width('100%')
+        .margin({ top: 10, bottom: 10 })
+        .justifyContent(FlexAlign.Start)
+
         Row() {
           Text('风格:')
             .fontSize(14)

+ 7 - 0
entry/src/main/ets/viewmodel/VideoItem.ets

@@ -57,6 +57,13 @@ export class VideoItem  {
   genre?:string//风格
   track?:string//音轨号
 
+  bits_per_raw_sample?:string//位深
+  channels?:string//声道数
+  channel_layout?:string//声道布局:stereo为标准立体声(左+右)
+  start_time?:string//起始时间:
+
+
+
   constructor(name: string, id: string, filePath: string, type:number,videoSize:number,cTime: string,pixelMap?: image.PixelMap,
     size?: string,pixelMapPath?: string,artist?: string,album?: string,fileName?: string, lastPlayed?:Date) {
     this.name = name;