|
|
@@ -61,7 +61,7 @@ import { image } from '@kit.ImageKit';
|
|
|
import { AVCastPicker, AVCastPickerState, AVCastPickerStyle, avSession } from '@kit.AVSessionKit';
|
|
|
import { UniversalDetector } from '@ohos/juniversalchardet';
|
|
|
import { SettingPage } from '../pages/SettingPage';
|
|
|
-import { secondToTime } from '../common/util/CommUtils';
|
|
|
+import { secondToTime,getTransverterText } from '../common/util/CommUtils';
|
|
|
import { CommonConstants2 } from '../common/util/CommonConstants2';
|
|
|
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
|
import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
|
@@ -666,6 +666,9 @@ export struct LocalMusic {
|
|
|
this.isSwipe = PreferencesUtil.getBooleanSync(SettingPage.IS_SWIPE, false)
|
|
|
this.openSkipSongAnimate = PreferencesUtil.getBooleanSync(SettingPage.OPEN_SKIPSONG_ANIMATE, true)
|
|
|
this.volumeSmall = PreferencesUtil.getBooleanSync('volumeSmall', false)
|
|
|
+ this.autoParseMusicName = PreferencesUtil.getBooleanSync('autoParseMusicName', false)
|
|
|
+
|
|
|
+
|
|
|
if(this.volumeSmall){
|
|
|
this.volume = 0.5
|
|
|
}else{
|
|
|
@@ -744,9 +747,11 @@ export struct LocalMusic {
|
|
|
// data2: this.rootPath,
|
|
|
// data3: this.lockPath,
|
|
|
// data4: PreferencesUtil.getStringSync('COVER_API', ''),
|
|
|
+ // data5: PreferencesUtil.getBooleanSync('autoParseMusicName', false),
|
|
|
// });
|
|
|
PreferencesUtil.putSync('isFirstApp', false)
|
|
|
} else {
|
|
|
+
|
|
|
workerInstance.postMessage({ code: 2, data: this.context });
|
|
|
workerInstance.postMessage({ code: 3, data: this.context });
|
|
|
workerInstance.postMessage({ code: 4, data: this.context });
|
|
|
@@ -767,7 +772,7 @@ export struct LocalMusic {
|
|
|
this.mediaKuList = e.data.data
|
|
|
Logger.info('onecold 查询媒体库列表 this.mediaKuList length= ' + this.mediaKuList.length)
|
|
|
Utility.doSortListAscending(this.mediaKuList)
|
|
|
- AppStorage.setOrCreate('mediaKuList', this.mediaKuList);
|
|
|
+ // AppStorage.setOrCreate('mediaKuList', this.mediaKuList);
|
|
|
if (this.modeType === 1) {
|
|
|
this.updateListData(this.mediaKuList)
|
|
|
}
|
|
|
@@ -831,7 +836,7 @@ export struct LocalMusic {
|
|
|
const documentViewPicker = new picker.DocumentViewPicker()
|
|
|
let documentSaveResult = await documentViewPicker.save({ pickerMode: picker.DocumentPickerMode.DOWNLOAD })
|
|
|
this.rootPath = new fileUri.FileUri(documentSaveResult[0]).path
|
|
|
- // this.rootPath = this.download_path
|
|
|
+ this.currentPath = this.rootPath
|
|
|
this.lockPath = this.rootPath + '/' + LocalMusic.STR_LOCK_VIDEO
|
|
|
this.favPath = this.rootPath + '/' + LocalMusic.STR_FAC_VIDEO
|
|
|
this.historyPath = this.rootPath + '/' + LocalMusic.STR_HISTORY_MUSIC
|
|
|
@@ -931,6 +936,7 @@ export struct LocalMusic {
|
|
|
|
|
|
async getSortedFiles(curPath: string, isWorkerPost?: boolean, destPath?: string, isOpen?: boolean) {
|
|
|
this.isFavMusic = false
|
|
|
+ console.info('onecold getSortedFiles 1 curPath '+curPath)
|
|
|
if (isWorkerPost) {
|
|
|
workerInstance.postMessage({ code: 2, data: this.context }); //刷新媒体库列表
|
|
|
}
|
|
|
@@ -938,8 +944,10 @@ export struct LocalMusic {
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+ console.info('onecold getSortedFiles 2')
|
|
|
this.isCanBack = false
|
|
|
this.currentPath = curPath
|
|
|
+ console.info('onecold getSortedFiles this.currentPath ='+this.currentPath)
|
|
|
this.titleBarModel.setTitleName(getFileDirName(this.currentPath, this.rootPath))
|
|
|
if (curPath === this.rootPath) {
|
|
|
this.titleBarModel.setLeftIconMain($r('app.media.menu'))
|
|
|
@@ -1104,7 +1112,7 @@ export struct LocalMusic {
|
|
|
// Process media files
|
|
|
if (!fPath.endsWith('.lrc') && Utility.isMeidaByExtension(fPath) && !fPath.endsWith('.srt')) {
|
|
|
let mediaItem: VideoItem =
|
|
|
- await Utility.uriGetMusicAssetsFromFile(this.context, fPath, CommonConstants.TYPE_LOCAL, true);
|
|
|
+ await Utility.uriGetMusicAssetsFromFile(this.context, fPath, CommonConstants.TYPE_LOCAL, this.autoParseMusicName);
|
|
|
mediaItems.push(mediaItem);
|
|
|
this.table.insert(mediaItem, (id: number) => {
|
|
|
|
|
|
@@ -1579,7 +1587,7 @@ export struct LocalMusic {
|
|
|
if (this.currentPath !== this.lockPath) { //判断不是私密音乐,才入库
|
|
|
if (!filePath.endsWith('.lrc') && Utility.isMeidaByExtension(filePath) && !filePath.endsWith('.srt')) {
|
|
|
let mediaItem: VideoItem =
|
|
|
- await Utility.uriGetMusicAssetsFromFile(this.context, filePath, CommonConstants.TYPE_LOCAL, true);
|
|
|
+ await Utility.uriGetMusicAssetsFromFile(this.context, filePath, CommonConstants.TYPE_LOCAL, this.autoParseMusicName);
|
|
|
this.table.insert(mediaItem, (id: number) => {
|
|
|
|
|
|
// 删除目标路径缓存
|
|
|
@@ -1769,7 +1777,7 @@ export struct LocalMusic {
|
|
|
// let newItem = new VideoItem(item.name,newPath,newPath,item.type,item.videoSize,item.cTime,item.pixelMap,
|
|
|
// item.size,item.pixelMapToString,item.artist,item.album,item.fileName)
|
|
|
let newItem: VideoItem = await Utility.uriGetMusicAssetsFromFile(this.context, newPath,
|
|
|
- CommonConstants.TYPE_LOCAL, true);
|
|
|
+ CommonConstants.TYPE_LOCAL, this.autoParseMusicName);
|
|
|
if (!newPath.includes(this.lockPath)) { //如果移动到私密,就不插入数据库
|
|
|
this.table.insert(newItem, (id: number) => {
|
|
|
//加入数据库
|
|
|
@@ -1844,7 +1852,7 @@ export struct LocalMusic {
|
|
|
// let newItem = new VideoItem(item.name,newPath,newPath,item.type,item.videoSize,item.cTime,item.pixelMap,
|
|
|
// item.size,item.pixelMapToString,item.artist,item.album,item.fileName)
|
|
|
let newItem: VideoItem = await Utility.uriGetMusicAssetsFromFile(this.context, newPath,
|
|
|
- CommonConstants.TYPE_LOCAL, true);
|
|
|
+ CommonConstants.TYPE_LOCAL, this.autoParseMusicName);
|
|
|
if (!newPath.includes(this.lockPath)) { //如果移动到私密,就不插入数据库
|
|
|
this.table.insert(newItem, (id: number) => {
|
|
|
//加入数据库
|
|
|
@@ -1920,7 +1928,7 @@ export struct LocalMusic {
|
|
|
}
|
|
|
|
|
|
let mediaItem: VideoItem =
|
|
|
- await Utility.uriGetMusicAssetsFromFile(this.context, newPath, CommonConstants.TYPE_LOCAL, true);
|
|
|
+ await Utility.uriGetMusicAssetsFromFile(this.context, newPath, CommonConstants.TYPE_LOCAL, this.autoParseMusicName);
|
|
|
|
|
|
this.videoLocalList[index] = mediaItem;
|
|
|
|
|
|
@@ -2231,6 +2239,7 @@ export struct LocalMusic {
|
|
|
data2: this.currentPath,
|
|
|
data3: this.lockPath,
|
|
|
data4: PreferencesUtil.getStringSync('COVER_API', ''),
|
|
|
+ data5: PreferencesUtil.getBooleanSync('autoParseMusicName', false),
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -2283,11 +2292,10 @@ export struct LocalMusic {
|
|
|
this.isMultiSelect = false
|
|
|
this.getUIContext().getPromptAction().closeCustomDialog(this.deleteComponentId)
|
|
|
},
|
|
|
- onDeleteResult:(result: boolean,item: VideoItem)=>{
|
|
|
+ onDeleteResult:(result: boolean)=>{
|
|
|
this.isMultiSelect = false
|
|
|
this.getUIContext().getPromptAction().closeCustomDialog(this.deleteComponentId)
|
|
|
if(result){//如果删除成功,更新数据
|
|
|
- this.videoLocalList = this.videoLocalList.filter(v => v !== item);
|
|
|
this.selectedFiles = [];
|
|
|
this.isAllSelected = false
|
|
|
this.cache.delete(this.currentPath);
|
|
|
@@ -2332,7 +2340,7 @@ export struct LocalMusic {
|
|
|
// let newItem = new VideoItem(item.name,newPath,newPath,item.type,item.videoSize,item.cTime,item.pixelMap,
|
|
|
// item.size,item.pixelMapToString,item.artist,item.album,item.fileName)
|
|
|
let newItem: VideoItem = await Utility.uriGetMusicAssetsFromFile(this.context, newPath,
|
|
|
- CommonConstants.TYPE_LOCAL, true);
|
|
|
+ CommonConstants.TYPE_LOCAL, this.autoParseMusicName);
|
|
|
if (!newPath.includes(this.lockPath)) { //如果移动到私密,就不插入数据库
|
|
|
this.table.insert(newItem, (id: number) => {
|
|
|
//加入数据库
|
|
|
@@ -2429,7 +2437,7 @@ export struct LocalMusic {
|
|
|
// item.size,item.pixelMapToString,item.artist,item.album,item.fileName)
|
|
|
|
|
|
let newItem: VideoItem = await Utility.uriGetMusicAssetsFromFile(this.context, newPath,
|
|
|
- CommonConstants.TYPE_LOCAL, true);
|
|
|
+ CommonConstants.TYPE_LOCAL, this.autoParseMusicName);
|
|
|
if (!newPath.includes(this.lockPath)) { //如果移动到私密,就不插入数据库
|
|
|
this.table.insert(newItem, (id: number) => {
|
|
|
//加入数据库
|
|
|
@@ -2790,7 +2798,7 @@ export struct LocalMusic {
|
|
|
.clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.6 })
|
|
|
.onClick(() => {
|
|
|
this.modeType = index;
|
|
|
- this.onModeChange();
|
|
|
+ // this.onModeChange();
|
|
|
});
|
|
|
}
|
|
|
.layoutWeight(1)
|
|
|
@@ -5667,6 +5675,39 @@ export struct LocalMusic {
|
|
|
.onClick( ()=>{
|
|
|
this.callFilePickerSelectFileForLyric()
|
|
|
})
|
|
|
+
|
|
|
+ Button({ type: ButtonType.Capsule, stateEffect: true }) {
|
|
|
+ SymbolGlyph($r('sys.symbol.traditional_square'))
|
|
|
+ .fontSize(25)
|
|
|
+ .alignSelf(ItemAlign.Center)
|
|
|
+ .margin({ left: 22,top:25})
|
|
|
+ }
|
|
|
+ .backgroundColor(Color.Transparent)
|
|
|
+ .visibility(StrUtil.isEmpty(this.tempLyricContent)&&StrUtil.isEmpty(this.lyricConStr)?
|
|
|
+ Visibility.None:Visibility.Visible)
|
|
|
+ .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
+ .onClick( ()=>{
|
|
|
+ let lyricC = StrUtil.isNotEmpty(this.lyricConStr)?this.lyricConStr: this.tempLyricContent
|
|
|
+ this.lyricConStr = getTransverterText(lyricC,1)//1是简体转繁体 ,2是繁体转简体
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ Button({ type: ButtonType.Capsule, stateEffect: true }) {
|
|
|
+ Image($r('app.media.jianti'))
|
|
|
+ .height(25)
|
|
|
+ .fillColor($r('app.color.text_color'))
|
|
|
+ .alignSelf(ItemAlign.Center)
|
|
|
+ .margin({ left: 22,top:25})
|
|
|
+ }
|
|
|
+ .backgroundColor(Color.Transparent)
|
|
|
+ .visibility(StrUtil.isEmpty(this.tempLyricContent)&&StrUtil.isEmpty(this.lyricConStr)?
|
|
|
+ Visibility.None:Visibility.Visible)
|
|
|
+ .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
+ .onClick( ()=>{
|
|
|
+ let lyricC = StrUtil.isNotEmpty(this.lyricConStr)?this.lyricConStr: this.tempLyricContent
|
|
|
+ this.lyricConStr = getTransverterText(lyricC,2)//1是简体转繁体 ,2是繁体转简体
|
|
|
+
|
|
|
+ })
|
|
|
}
|
|
|
.layoutWeight(1)
|
|
|
|
|
|
@@ -5686,7 +5727,7 @@ export struct LocalMusic {
|
|
|
})
|
|
|
}
|
|
|
.width('100%')
|
|
|
- .height(StrUtil.isEmpty(this.lyricConStr)&&StrUtil.isEmpty(this.tempLyricContent)?100:'auto')
|
|
|
+ .height(StrUtil.isEmpty(this.lyricConStr)&&StrUtil.isEmpty(this.tempLyricContent)?120:'auto')
|
|
|
.margin({ top: 10, bottom: 10 })
|
|
|
.justifyContent(FlexAlign.Start)
|
|
|
|
|
|
@@ -7363,6 +7404,8 @@ export struct LocalMusic {
|
|
|
private windowClass: window.Window = globalThis.windowClass
|
|
|
@State volume: number = 0.5;
|
|
|
@State volumeSmall: boolean = false
|
|
|
+ @State autoParseMusicName: boolean = false
|
|
|
+
|
|
|
@State volumeShow: boolean = PlayConstants.VOLUME_SHOW;
|
|
|
@State bright: number = PlayConstants.BRIGHT;
|
|
|
@State brightShow: boolean = PlayConstants.BRIGHT_SHOW;
|