|
@@ -56,6 +56,7 @@ import fs from '@ohos.file.fs';
|
|
|
import { image } from '@kit.ImageKit';
|
|
import { image } from '@kit.ImageKit';
|
|
|
import { AVCastPicker, AVCastPickerState, AVCastPickerStyle, avSession } from '@kit.AVSessionKit';
|
|
import { AVCastPicker, AVCastPickerState, AVCastPickerStyle, avSession } from '@kit.AVSessionKit';
|
|
|
import * as chardet from '@changwei/chardet';
|
|
import * as chardet from '@changwei/chardet';
|
|
|
|
|
+import { UniversalDetector } from '@ohos/juniversalchardet';
|
|
|
import { SettingPage } from '../pages/SettingPage';
|
|
import { SettingPage } from '../pages/SettingPage';
|
|
|
import { secondToTime } from '../common/util/CommUtils';
|
|
import { secondToTime } from '../common/util/CommUtils';
|
|
|
import { CommonConstants2 } from '../common/util/CommonConstants2';
|
|
import { CommonConstants2 } from '../common/util/CommonConstants2';
|
|
@@ -4409,6 +4410,8 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// readCoverInfo(inputPath:string,outputPath:string){
|
|
// readCoverInfo(inputPath:string,outputPath:string){
|
|
|
|
|
+ // console.info("onecold FFmpeg inputPath = "+inputPath);
|
|
|
|
|
+ // console.info("onecold FFmpeg outputPath = "+outputPath);
|
|
|
// let commands = ["ffmpeg", "-i", inputPath, "-f ffmetadata",outputPath];
|
|
// let commands = ["ffmpeg", "-i", inputPath, "-f ffmetadata",outputPath];
|
|
|
// FFmpeg.execute(commands, {
|
|
// FFmpeg.execute(commands, {
|
|
|
// logCallback: (logLevel: number, logMessage: string) => console.log(`[${logLevel}]${logMessage}`),
|
|
// logCallback: (logLevel: number, logMessage: string) => console.log(`[${logLevel}]${logMessage}`),
|
|
@@ -6318,13 +6321,15 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
// 检测文件编码
|
|
// 检测文件编码
|
|
|
- let detectedEncoding = chardet.detect(buf);
|
|
|
|
|
- console.info("Detected encoding: " + detectedEncoding);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // let detectedEncoding = chardet.detect(buf);
|
|
|
|
|
+ // console.info("onecoldT Detected encoding: " + detectedEncoding);
|
|
|
|
|
+ let detectedEncoding = this.detect(arrayBuffer)
|
|
|
|
|
+ console.info("onecoldT Detected encoding: " + detectedEncoding);
|
|
|
// 使用检测到的编码解码,解决中文乱码问题
|
|
// 使用检测到的编码解码,解决中文乱码问题
|
|
|
let textDecoder = new util.TextDecoder(detectedEncoding || 'utf-8');
|
|
let textDecoder = new util.TextDecoder(detectedEncoding || 'utf-8');
|
|
|
|
|
+ console.info("onecoldT Detected textDecoder: " + textDecoder);
|
|
|
let fileContent = textDecoder.decode(buf);
|
|
let fileContent = textDecoder.decode(buf);
|
|
|
- console.info(`onecold The content of file1: ${fileContent}`);
|
|
|
|
|
|
|
+ console.info(`onecoldT The content of file1: ${fileContent}`);
|
|
|
//解密
|
|
//解密
|
|
|
if (isJiaMi) {
|
|
if (isJiaMi) {
|
|
|
fileContent = StrUtil.unit8ArrayToStr(Base64Util.decodeSync(fileContent))
|
|
fileContent = StrUtil.unit8ArrayToStr(Base64Util.decodeSync(fileContent))
|
|
@@ -6376,6 +6381,21 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ detect(data: ArrayBuffer): string {
|
|
|
|
|
+ //创建检测对象
|
|
|
|
|
+ let detector: UniversalDetector = new UniversalDetector();
|
|
|
|
|
+ // 传入检测数据并实时判断编码格式
|
|
|
|
|
+ detector.handleData(data, 0, data.byteLength);
|
|
|
|
|
+ // 标记检测数据 读取结束
|
|
|
|
|
+ detector.dataEnd();
|
|
|
|
|
+ // 获取检测结果
|
|
|
|
|
+ let detected: string = detector.getDetectedCharset();
|
|
|
|
|
+ // 释放资源
|
|
|
|
|
+ detector.reset();
|
|
|
|
|
+
|
|
|
|
|
+ return detected;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//初始化悬浮歌词的自定义设置
|
|
//初始化悬浮歌词的自定义设置
|
|
|
initPipLyricSetting() {
|
|
initPipLyricSetting() {
|
|
|
this.lyricControllerXF
|
|
this.lyricControllerXF
|
|
@@ -6439,7 +6459,8 @@ export struct LocalMusic {
|
|
|
throw new Error("Buffer is empty after reading the file");
|
|
throw new Error("Buffer is empty after reading the file");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- let detectedEncoding = chardet.detect(buf);
|
|
|
|
|
|
|
+ // let detectedEncoding = chardet.detect(buf);
|
|
|
|
|
+ let detectedEncoding = this.detect(arrayBuffer)
|
|
|
console.info("Detected encoding: " + detectedEncoding);
|
|
console.info("Detected encoding: " + detectedEncoding);
|
|
|
|
|
|
|
|
let textDecoder = new util.TextDecoder(detectedEncoding || 'utf-8');
|
|
let textDecoder = new util.TextDecoder(detectedEncoding || 'utf-8');
|