|
|
@@ -7819,7 +7819,9 @@ export struct LocalMusic {
|
|
|
tempOutPath = ''
|
|
|
}
|
|
|
const isWav:boolean = newInput.toLowerCase().endsWith('.wav')
|
|
|
- ||newInput.toLowerCase().endsWith('.ape');
|
|
|
+ ||newInput.toLowerCase().endsWith('.ape')
|
|
|
+ ||newInput.toLowerCase().endsWith('.dsf')
|
|
|
+ ||newInput.toLowerCase().endsWith('.dff');
|
|
|
//内嵌下标签的值,设置overwrite为true会直接修改原文件
|
|
|
const result:boolean = await repairAudioMetadata(
|
|
|
newInput,
|
|
|
@@ -7860,7 +7862,7 @@ export struct LocalMusic {
|
|
|
if (result) {
|
|
|
console.log(" onecold 编辑信息成功,数据库已同步");
|
|
|
if(isWav){
|
|
|
- ToastUtil.showToast('wav或者ape格式有可能内嵌失败,但是编辑信息成功')
|
|
|
+ ToastUtil.showToast('dsf、wav、dff或者ape格式有可能内嵌失败,但是编辑信息成功')
|
|
|
}else{
|
|
|
ToastUtil.showToast('内嵌音乐标签成功')
|
|
|
}
|
|
|
@@ -10242,7 +10244,6 @@ export struct LocalMusic {
|
|
|
this.loadLyricTimeOffset()
|
|
|
this.lyricController.setLyric(null)
|
|
|
this.lyricControllerSingle.setLyric(null)
|
|
|
- let jiaMilyricPath = lyricPath.substring(0, lyricPath.lastIndexOf('.')) + '.lrcc'
|
|
|
console.log("onecold lyricPath =" + lyricPath)
|
|
|
|
|
|
// 1. 检查内嵌歌词
|
|
|
@@ -10307,34 +10308,23 @@ export struct LocalMusic {
|
|
|
}
|
|
|
|
|
|
// 3. 尝试在线歌词API
|
|
|
- if (isOnLineAndToast || ((!FileUtil.accessSync(lyricPath) && !FileUtil.accessSync(jiaMilyricPath))
|
|
|
+ if (isOnLineAndToast || ((!FileUtil.accessSync(lyricPath))
|
|
|
&& !Utility.isVideoByExtension(this.videoUrl))) {
|
|
|
this.fetchOnlineLyric(lyricPath, isOnLineAndToast || false, isApi2);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 4. 从本地文件读取歌词
|
|
|
- await this.loadLyricFromFile(lyricPath, jiaMilyricPath, isLocal || false);
|
|
|
+ await this.loadLyricFromFile(lyricPath, isLocal || false);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 从本地文件加载歌词
|
|
|
*/
|
|
|
- private async loadLyricFromFile(lyricPath: string, jiaMilyricPath: string, isLocal: boolean): Promise<void> {
|
|
|
+ private async loadLyricFromFile(lyricPath: string, isLocal: boolean): Promise<void> {
|
|
|
try {
|
|
|
- let isJiaMi = false;
|
|
|
let realLyricPath = lyricPath;
|
|
|
|
|
|
- if (FileUtil.accessSync(jiaMilyricPath)) {
|
|
|
- isJiaMi = true;
|
|
|
- realLyricPath = jiaMilyricPath;
|
|
|
- console.info("onecold 找到加密本地歌词 ");
|
|
|
- } else {
|
|
|
- isJiaMi = false;
|
|
|
- realLyricPath = lyricPath;
|
|
|
- console.info("onecold 找到本地歌词 ");
|
|
|
- }
|
|
|
-
|
|
|
// 读取文件内容
|
|
|
let file = fs.openSync(realLyricPath, fs.OpenMode.READ_ONLY);
|
|
|
const stat = await fileIo.stat(file.fd);
|
|
|
@@ -10360,10 +10350,6 @@ export struct LocalMusic {
|
|
|
let fileContent = textDecoder.decode(buf);
|
|
|
console.info(`onecoldT The content of file1: ${fileContent}`);
|
|
|
|
|
|
- // 解密
|
|
|
- if (isJiaMi) {
|
|
|
- fileContent = StrUtil.unit8ArrayToStr(Base64Util.decodeSync(fileContent));
|
|
|
- }
|
|
|
|
|
|
console.info(`onecold The content of file2: ${fileContent}`);
|
|
|
this.lyricContent = fileContent;
|
|
|
@@ -10401,8 +10387,14 @@ export struct LocalMusic {
|
|
|
detect(data: ArrayBuffer): string {
|
|
|
//创建检测对象
|
|
|
let detector: UniversalDetector = new UniversalDetector();
|
|
|
+
|
|
|
+ // 限制检测数据大小,避免内存溢出
|
|
|
+ // 通常只需要检测文件前16KB就足够判断编码格式
|
|
|
+ const MAX_DETECT_SIZE = 16 * 1024; // 16KB
|
|
|
+ const detectSize = Math.min(data.byteLength, MAX_DETECT_SIZE);
|
|
|
+
|
|
|
// 传入检测数据并实时判断编码格式
|
|
|
- detector.handleData(data, 0, data.byteLength);
|
|
|
+ detector.handleData(data, 0, detectSize);
|
|
|
// 标记检测数据 读取结束
|
|
|
detector.dataEnd();
|
|
|
// 获取检测结果
|
|
|
@@ -10410,6 +10402,8 @@ export struct LocalMusic {
|
|
|
// 释放资源
|
|
|
detector.reset();
|
|
|
|
|
|
+ Logger.info(TAG, "heanup detect encoding: " + detected + ", data size: " + data.byteLength + ", detect size: " + detectSize);
|
|
|
+
|
|
|
return detected;
|
|
|
}
|
|
|
|
|
|
@@ -10435,7 +10429,7 @@ export struct LocalMusic {
|
|
|
|
|
|
// 如果提供了保存路径,保存歌词到本地
|
|
|
if (savePath) {
|
|
|
- this.saveDataToFile(lyricText, savePath, false);
|
|
|
+ this.saveDataToFile(lyricText, savePath);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -10535,18 +10529,8 @@ export struct LocalMusic {
|
|
|
try {
|
|
|
let filePath = item.filePath;
|
|
|
let lyricPath = filePath.substring(0, filePath.lastIndexOf('.')) + '.lrc';
|
|
|
- let jiaMilyricPath = lyricPath.substring(0, lyricPath.lastIndexOf('.')) + '.lrcc';
|
|
|
- let isJiaMi = false;
|
|
|
let realLyricPath = lyricPath;
|
|
|
|
|
|
- if (FileUtil.accessSync(jiaMilyricPath)) {
|
|
|
- isJiaMi = true;
|
|
|
- realLyricPath = jiaMilyricPath;
|
|
|
- console.info("onecold 找到加密本地歌词");
|
|
|
- } else {
|
|
|
- console.info("onecold 找到本地歌词");
|
|
|
- }
|
|
|
-
|
|
|
let file = fs.openSync(realLyricPath, fs.OpenMode.READ_ONLY);
|
|
|
const stat = await fileIo.stat(file.fd);
|
|
|
const arrayBuffer = new ArrayBuffer(stat.size);
|
|
|
@@ -10568,11 +10552,6 @@ export struct LocalMusic {
|
|
|
let fileContent = textDecoder.decode(buf);
|
|
|
console.info(`onecold The content of file1: ${fileContent}`);
|
|
|
|
|
|
- if (isJiaMi) {
|
|
|
- fileContent = StrUtil.unit8ArrayToStr(Base64Util.decodeSync(fileContent));
|
|
|
- }
|
|
|
- console.info(`onecold The content of file2: ${fileContent}`);
|
|
|
-
|
|
|
fs.closeSync(file);
|
|
|
return fileContent;
|
|
|
|
|
|
@@ -10582,21 +10561,14 @@ export struct LocalMusic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async saveDataToFile(content: string, filePath: string, isJiaMi?: boolean) {
|
|
|
+ async saveDataToFile(content: string, filePath: string) {
|
|
|
if (StrUtil.isEmpty(filePath)) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- //将content进行加密
|
|
|
- // let jiaMilyricPath = filePath.substring(0,filePath.lastIndexOf('.'))+'.lrcc'
|
|
|
let lyricContent = ''
|
|
|
- if (isJiaMi) {
|
|
|
- lyricContent = Base64Util.encodeToStrSync(StrUtil.strToUint8Array(content))
|
|
|
- } else {
|
|
|
- lyricContent = content
|
|
|
- }
|
|
|
-
|
|
|
+ lyricContent = content
|
|
|
const file = await fileIo.open(filePath, fileIo.OpenMode.CREATE | fileIo.OpenMode.READ_WRITE);
|
|
|
// 清空文件内容
|
|
|
await fileIo.truncate(file.fd, 0);
|
|
|
@@ -12882,7 +12854,8 @@ export struct LocalMusic {
|
|
|
.fontSize(24)
|
|
|
.fontColor([Color.White])
|
|
|
.alignSelf(ItemAlign.Center)
|
|
|
- .margin({ left: 10, right: 10 })
|
|
|
+ .margin({ left: 10, right: 10,bottom:5})
|
|
|
+ // .padding({bottom:4})
|
|
|
.onClick(() => {
|
|
|
this.doMore(more.id)
|
|
|
})
|
|
|
@@ -12898,7 +12871,7 @@ export struct LocalMusic {
|
|
|
}
|
|
|
Text(more.id == 17 ? (this.isLandscape ? '竖屏模式' : '横屏模式') : more.title)
|
|
|
.fontSize(16)
|
|
|
-
|
|
|
+ .margin({top:more.id >= 22?3:0})
|
|
|
.fontColor(Color.White)
|
|
|
.onClick(() => {
|
|
|
this.doMore(more.id)
|
|
|
@@ -13064,6 +13037,7 @@ export struct LocalMusic {
|
|
|
.font({ size: 14, weight: FontWeight.Medium })
|
|
|
.fontColor(Color.White)
|
|
|
.margin({ left: 25 })
|
|
|
+ .margin({top:more.id >= 22?3:0})
|
|
|
.visibility(more.id === 26 ? Visibility.Visible : Visibility.None)
|
|
|
.selected(this.spectrumModeIndex)
|
|
|
.value(['柱状', '波形', '圆形', '粒子', '脉冲', '镜像柱', '影子柱', '轨道线', '点阵', '星爆'][this.spectrumModeIndex])
|