|
|
@@ -174,6 +174,7 @@ const ITEM_HEIGHT_BIG: number = 78; // 列表项大高度
|
|
|
@Preview
|
|
|
@Component
|
|
|
export struct LocalMusic {
|
|
|
+ @State isCopyFileToDownLoad: boolean = false
|
|
|
@State offHeight: number = 75
|
|
|
@State currentSongList: Array<VideoItem> = []//当前歌单
|
|
|
@Consume currentSongListName:string //当前歌单名称
|
|
|
@@ -874,6 +875,7 @@ export struct LocalMusic {
|
|
|
this.isLongNameRoLL = PreferencesUtil.getBooleanSync('isLongNameRoLL', true)
|
|
|
this.fastForwardSeconds = PreferencesUtil.getStringSync('fastForwardSeconds', '10')
|
|
|
this.isShowBackFast = PreferencesUtil.getBooleanSync('isShowBackFast', false)
|
|
|
+ this.isCopyFileToDownLoad = PreferencesUtil.getBooleanSync(SettingPage.IS_COPYFILE_TO_DOWNLOAD, false)
|
|
|
if(this.volumeSmall){
|
|
|
this.volume = 0.5
|
|
|
}else{
|
|
|
@@ -1816,8 +1818,76 @@ export struct LocalMusic {
|
|
|
}
|
|
|
|
|
|
@State progress: number = 0;
|
|
|
+ async saveVideoDatas(uris:string[],isOpen?:boolean){
|
|
|
+ if (ArrayUtil.isEmpty(uris)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ console.info('onecold this.isCopyFileToDownLoad = ' + this.isCopyFileToDownLoad);
|
|
|
+ if(this.isCopyFileToDownLoad||this.currentPath==this.lockPath){
|
|
|
+ this.saveVideoDatasToDownLoad(uris,isOpen)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 初始化进度条
|
|
|
+ this.progress = 0;
|
|
|
+ DialogHelper.showLoadingProgress({
|
|
|
+ progress: this.progress,
|
|
|
+ backCancel: false,
|
|
|
+ autoCancel: false,
|
|
|
+ loadColor: $r('app.color.title_bar_bg'),
|
|
|
+ fontColor: $r('app.color.title_bar_bg')
|
|
|
+ });
|
|
|
+
|
|
|
+ // 计算处理总数用于进度计算
|
|
|
+ const totalItems = uris.length;
|
|
|
+ let processedItems = 0;
|
|
|
+
|
|
|
+ for (let i = 0; i < uris.length; i++) {
|
|
|
+ let filePath = uris[i];
|
|
|
+ try {
|
|
|
+ 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, this.autoParseMusicName);
|
|
|
+ console.info('onecold saveVideoDatas filePath = ' + filePath)
|
|
|
+ if (!filePath.includes(this.rootPath)) {
|
|
|
+ console.info('onecold saveVideoDatas mediaItem.parentPath111 = ' + mediaItem.parentPath)
|
|
|
+ mediaItem.parentPath = this.currentPath;
|
|
|
+ }
|
|
|
+ console.info('onecold saveVideoDatas mediaItem.parentPath = ' + mediaItem.parentPath)
|
|
|
+ this.table.insert(mediaItem, (id: number) => {
|
|
|
+ // 插入完成回调
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新进度
|
|
|
+ processedItems++;
|
|
|
+ this.progress = Math.floor((processedItems / totalItems) * 100);
|
|
|
+ DialogHelper.updateLoading(' 正在处理', this.progress);
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ Logger.error(TAG, 'saveVideoDatas failed with err: ' + JSON.stringify(error));
|
|
|
+ // 即使出错也更新进度
|
|
|
+ processedItems++;
|
|
|
+ this.progress = Math.floor((processedItems / totalItems) * 100);
|
|
|
+ DialogHelper.updateLoading(' 正在处理', this.progress);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 关闭进度条
|
|
|
+ DialogHelper.closeLoading();
|
|
|
+ this.isZero = false
|
|
|
+ // 删除目标路径缓存
|
|
|
+ setTimeout(() => {
|
|
|
+ this.cache.delete(this.currentPath);
|
|
|
+ this.getSortedFiles(this.currentPath,false,uris[0],isOpen)
|
|
|
+ this.setButtonStatus()
|
|
|
+ }, 500);
|
|
|
|
|
|
- async saveVideoDatas(uris: string[], isOpen?: boolean) {
|
|
|
+ }
|
|
|
+ async saveVideoDatasToDownLoad(uris: string[], isOpen?: boolean) {
|
|
|
if (ArrayUtil.isEmpty(uris)) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -9457,7 +9527,7 @@ export struct LocalMusic {
|
|
|
.width('99%')
|
|
|
.textAlign(TextAlign.Center)
|
|
|
.fontColor(Color.White)
|
|
|
- Text(this.artist + ' ' + this.currentSong?.album)
|
|
|
+ Text(this.artist + ' ' + this.currentSong?.album||'')
|
|
|
.fontSize(this.isCoverOpacity() ? 12 : 15)
|
|
|
.textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
|
|
|
.fontColor(Color.White)
|