|
|
@@ -405,7 +405,12 @@ export struct LocalMusic {
|
|
|
// 监听ScanFilePage广播事件(更新数据库)
|
|
|
emitter.on(eventScanUpdate, (eventData: emitter.EventData) => {
|
|
|
this.doUpdateData()
|
|
|
+ });
|
|
|
|
|
|
+ let eventSetting: emitter.InnerEvent = { eventId: 333 }
|
|
|
+ // 监听广播事件(打开其他应用处理)
|
|
|
+ emitter.on(eventSetting, (eventData: emitter.EventData) => {
|
|
|
+ this.doChangeSetting()
|
|
|
|
|
|
});
|
|
|
|
|
|
@@ -440,6 +445,14 @@ export struct LocalMusic {
|
|
|
this.isCoverRectangle = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_RECTANGLE, false)
|
|
|
}
|
|
|
|
|
|
+ doChangeSetting(){
|
|
|
+ this.sortType = PreferencesUtil.getNumberSync(SettingPage.SORT_TYPE, 4)
|
|
|
+ this.isCustomizeBg = PreferencesUtil.getBooleanSync(SettingPage.IS_CUSTOMIZE_BG, false)
|
|
|
+ this.customizeBgPath = PreferencesUtil.getStringSync(SettingPage.IS_CUSTOMIZE_BG_PATH, '')
|
|
|
+
|
|
|
+ this.doUpdateData()
|
|
|
+ }
|
|
|
+
|
|
|
doChangeBarHeight() {
|
|
|
if (this.currentWidthBreakpoint !== WidthBreakpoint.WIDTH_SM ||
|
|
|
(this.currentHeightBreakpoint !== HeightBreakpoint.HEIGHT_MD &&
|
|
|
@@ -749,116 +762,6 @@ export struct LocalMusic {
|
|
|
|
|
|
}
|
|
|
|
|
|
- // async getSortedFiles(curPath:string,isWorkerPost?:boolean,destPath?:string,isOpen?:boolean){
|
|
|
- // if(isWorkerPost){
|
|
|
- // workerInstance.postMessage({ code: 2, data: this.context });
|
|
|
- // }
|
|
|
- // if(this.modeType!==0){
|
|
|
- //
|
|
|
- // return
|
|
|
- // }
|
|
|
- // this.isHistory = false
|
|
|
- // this.isCanBack = false
|
|
|
- // this.currentPath = curPath
|
|
|
- // this.titleBarModel.setTitleName(Utility.getFileDirName(this.currentPath,this.rootPath))
|
|
|
- // if(curPath === this.rootPath){
|
|
|
- // this.titleBarModel.setLeftIconMain($r('app.media.menu'))
|
|
|
- // }else{
|
|
|
- //
|
|
|
- // if(this.rootPath === Utility.getParentDirectory(curPath))
|
|
|
- // this.titleBarModel.setLeftIconMain($r('app.media.left_back_white'))
|
|
|
- // }
|
|
|
- //
|
|
|
- // // Get the current file list and calculate its hash
|
|
|
- //
|
|
|
- // this.fileList = FileUtil.listFileSync(curPath);
|
|
|
- //
|
|
|
- // const currentHash = simpleHash(this.fileList);
|
|
|
- //
|
|
|
- //
|
|
|
- // // Check cache
|
|
|
- // const cachedValue = this.findCache(curPath);
|
|
|
- // const cachedHash = this.findStringCache(curPath + '_hash');
|
|
|
- // const cachedDirList= this.findCache(curPath+"_dirList");
|
|
|
- // if(cachedValue!==undefined){
|
|
|
- // // this.videoLocalList = cachedValue;
|
|
|
- // this.updateListData(cachedValue)
|
|
|
- // }
|
|
|
- //
|
|
|
- // if(cachedDirList!==undefined)
|
|
|
- // this.dirList = cachedDirList
|
|
|
- // //通过当前hash值和缓存hash判断list有没有变化
|
|
|
- // if (cachedValue && cachedHash === currentHash) {
|
|
|
- // // this.updatePixelMaps(curPath)
|
|
|
- // // this.setButtonStatus();
|
|
|
- //
|
|
|
- // return;
|
|
|
- // }
|
|
|
- //
|
|
|
- // this.fileList = FileUtil.listFileSync(curPath)
|
|
|
- // let directories: Array<VideoItem> = [];
|
|
|
- // let files: Array<VideoItem> = [];
|
|
|
- // for (let i = 0; i < this.fileList.length; i++) {
|
|
|
- // console.info(`The name of file: ${this.fileList[i]}`);
|
|
|
- // let path = curPath+'/'+this.fileList[i]
|
|
|
- // if(FileUtil.isDirectory(path)){
|
|
|
- // let item:VideoItem = new VideoItem(this.fileList[i].toString(),this.fileList[i].toString(),path,CommonConstants.TYPE_IS_DIR,0,'')
|
|
|
- //
|
|
|
- // directories.push(item);
|
|
|
- // directories.sort((a, b) => a.cTime.localeCompare(b.cTime));
|
|
|
- // Utility.doSortListAscending(directories)
|
|
|
- //
|
|
|
- // }else{
|
|
|
- // let item:VideoItem = await Utility.uriGetMusicAssetsFromFile(this.context,path,CommonConstants.TYPE_LOCAL,false);
|
|
|
- // if(!path.endsWith('.lrc')&&Utility.isMeidaByExtension(path)&&!path.endsWith('.srt')){
|
|
|
- // files.push(item);
|
|
|
- // files.sort((a, b) => a.cTime.localeCompare(b.cTime));
|
|
|
- // Utility.doSortListAscending(files)
|
|
|
- // }
|
|
|
- //
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // if(this.currentPath===this.rootPath){
|
|
|
- // this.dirList = directories
|
|
|
- // this.addCache(curPath+"_dirList", this.dirList);
|
|
|
- // }
|
|
|
- //
|
|
|
- // if(this.isShowAd&&ArrayUtil.isNotEmpty(directories)){
|
|
|
- // let adItem:VideoItem = new VideoItem('','','',CommonConstants.TYPE_IS_CSJAD,0,'')
|
|
|
- // directories.push(adItem)
|
|
|
- // }
|
|
|
- // // 合并文件夹和文件,文件夹在前,文件在后,广告在中间
|
|
|
- // this.videoLocalList = directories.concat(files);
|
|
|
- // this.dataSource.pushArrayData(this.videoLocalList);
|
|
|
- //
|
|
|
- // this.addCache(curPath, this.videoLocalList);
|
|
|
- // await this.saveCacheToStorage(); // 保存缓存至本地存储
|
|
|
- //
|
|
|
- // console.info(`gengxin 1: ${this.videoLocalList.length}`);
|
|
|
- // // this.updatePixelMaps(curPath)
|
|
|
- // this.addStringCache(curPath + '_hash', currentHash);
|
|
|
- // // this.setButtonStatus()
|
|
|
- // if(isOpen){
|
|
|
- //
|
|
|
- // if (destPath === undefined) {
|
|
|
- // // 处理 destPath 为 undefined 的情况
|
|
|
- // return
|
|
|
- // }
|
|
|
- // if(destPath.endsWith('.lrc')){
|
|
|
- // ToastUtil.showToast('导入歌词成功!请注意歌词文件和歌曲要同个歌单路径。')
|
|
|
- // if(StrUtil.isNotEmpty(this.videoUrl)){
|
|
|
- // let lyricPath = this.videoUrl.substring(0,this.videoUrl.lastIndexOf('.'))+'.lrc'
|
|
|
- // this.initLyric(lyricPath);
|
|
|
- // }
|
|
|
- //
|
|
|
- // return
|
|
|
- // }
|
|
|
- // let item2 = new VideoItem(Utility.getMediaNameByUri(destPath),destPath,destPath,0,0,'')
|
|
|
- // this.doPlay(item2)
|
|
|
- // }
|
|
|
- //
|
|
|
- // }
|
|
|
|
|
|
//扫描文件夹入库
|
|
|
async scanDirectory(curPath: string): Promise<VideoItem[]> {
|
|
|
@@ -3909,7 +3812,7 @@ export struct LocalMusic {
|
|
|
})
|
|
|
|
|
|
Button() {
|
|
|
- Image($r('app.media.close'))
|
|
|
+ Image($r('app.media.ic_close'))
|
|
|
.fillColor(Color.White)
|
|
|
.width(13)
|
|
|
}
|