|
@@ -123,6 +123,15 @@ export class Utility {
|
|
|
result.setDate(result.getDate() + days);
|
|
result.setDate(result.getDate() + days);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ static convertToKHz(sampleRateHz: string|undefined): string {
|
|
|
|
|
+ if(StrUtil.isEmpty(sampleRateHz)||sampleRateHz ===undefined)
|
|
|
|
|
+ return '0KHz'
|
|
|
|
|
+
|
|
|
|
|
+ const sampleRateKHz = Number(sampleRateHz) / 1000;
|
|
|
|
|
+ return `${sampleRateKHz} KHz`;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//根据字节获取大小
|
|
//根据字节获取大小
|
|
|
static formatFileSize(bytes:number) {
|
|
static formatFileSize(bytes:number) {
|
|
|
const units = ['Bytes', 'Kbps', 'Mbps'];
|
|
const units = ['Bytes', 'Kbps', 'Mbps'];
|
|
@@ -627,6 +636,11 @@ export class Utility {
|
|
|
let pixelMap:image.PixelMap|undefined|null = undefined
|
|
let pixelMap:image.PixelMap|undefined|null = undefined
|
|
|
let imagePath = ''
|
|
let imagePath = ''
|
|
|
|
|
|
|
|
|
|
+ let duration:string | undefined = ''
|
|
|
|
|
+ let mimeType:string | undefined = ''
|
|
|
|
|
+ let trackCount:string | undefined = ''//轨道数量
|
|
|
|
|
+ let sampleRate:string | undefined = ''//音频的采样率单位为Hz
|
|
|
|
|
+
|
|
|
if (canIUse("SystemCapability.Multimedia.Media.AVMetadataExtractor")) {
|
|
if (canIUse("SystemCapability.Multimedia.Media.AVMetadataExtractor")) {
|
|
|
try {
|
|
try {
|
|
|
// 创建AVMetadataExtractor对象
|
|
// 创建AVMetadataExtractor对象
|
|
@@ -653,6 +667,19 @@ export class Utility {
|
|
|
album = metadata.album
|
|
album = metadata.album
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if(StrUtil.isNotEmpty(metadata.duration)){
|
|
|
|
|
+ duration = metadata.duration
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StrUtil.isNotEmpty(metadata.mimeType)){
|
|
|
|
|
+ mimeType = metadata.mimeType
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StrUtil.isNotEmpty(metadata.trackCount)){
|
|
|
|
|
+ trackCount = metadata.trackCount
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StrUtil.isNotEmpty(metadata.sampleRate)){
|
|
|
|
|
+ sampleRate = metadata.sampleRate
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
let name = await MD5.digestSync(uri)
|
|
let name = await MD5.digestSync(uri)
|
|
|
|
|
|
|
|
if(isLoadPixelMap){
|
|
if(isLoadPixelMap){
|
|
@@ -695,6 +722,10 @@ export class Utility {
|
|
|
|
|
|
|
|
item = new VideoItem(musicName,uri ,uri,type,videoSize,addTime,undefined,fileSize,
|
|
item = new VideoItem(musicName,uri ,uri,type,videoSize,addTime,undefined,fileSize,
|
|
|
imagePath,artist,album,file.name)
|
|
imagePath,artist,album,file.name)
|
|
|
|
|
+ item.duration = duration+'';
|
|
|
|
|
+ item.mimeType = mimeType;
|
|
|
|
|
+ item.trackCount = trackCount;
|
|
|
|
|
+ item.sampleRate = sampleRate;
|
|
|
item.isFav = 0;
|
|
item.isFav = 0;
|
|
|
|
|
|
|
|
})
|
|
})
|