|
|
@@ -89,7 +89,7 @@ import { CueComptent } from '../view/CueComptent';
|
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
|
import { showAddToPlaylistDialog } from '../dialog/AddToPlaylistDialog';
|
|
|
import { showCreatePlaylistDialog } from '../dialog/PlaylistDialog';
|
|
|
-import { convertPlaylistSongsToVideoItems, emptyView } from '../pages/PlaylistDetailPage';
|
|
|
+import { convertPlaylistSongsToVideoItems, emptyView,updateAllSongsSortOrder } from '../pages/PlaylistDetailPage';
|
|
|
import { Playlist, PlaylistSong } from '../viewmodel/Playlist';
|
|
|
import { WebdavManager, WebDavAuthItem} from '../common/util/WebdavManager';
|
|
|
import { WebDavUrlUtil } from '../common/util/WebDavUrlUtil';
|
|
|
@@ -204,6 +204,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 //当前歌单名称
|
|
|
@@ -247,7 +248,7 @@ export struct LocalMusic {
|
|
|
@State isZero: boolean = false
|
|
|
@State fileList: Array<string> = []
|
|
|
@State dirList: Array<VideoItem> = []
|
|
|
- @Consume videoLocalList: Array<VideoItem>
|
|
|
+ @Consume videoLocalList:VideoItem[]
|
|
|
@State dataSource: LazyDataSource<VideoItem> = new LazyDataSource(this.videoLocalList)
|
|
|
// @State mediaKuList: Array<VideoItem> = []; //媒体库文件
|
|
|
@StorageProp('mediaKuList') mediaKuList: Array<VideoItem> = []; //媒体库文件
|
|
|
@@ -407,9 +408,8 @@ export struct LocalMusic {
|
|
|
} else {
|
|
|
PreferencesUtil.putSync(this.currentSongListID+'currentSongList', JSON.stringify(this.currentSongList));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
+ this.isRefreshing = false
|
|
|
}
|
|
|
|
|
|
onModeChange() {
|
|
|
@@ -640,6 +640,9 @@ export struct LocalMusic {
|
|
|
}
|
|
|
// 组件生命周期
|
|
|
aboutToAppear() {
|
|
|
+ if(ArrayUtil.isNotEmpty(this.videoLocalList)&&this.modeType==0){
|
|
|
+ this.updateListData(this.videoLocalList)
|
|
|
+ }
|
|
|
// 初始化 PlaylistTable
|
|
|
this.playlistTable = new PlaylistTable(getContext(this))
|
|
|
|
|
|
@@ -723,6 +726,15 @@ export struct LocalMusic {
|
|
|
Logger.error('heanup eventPlaylistPlay: 接收到无效的数据结构')
|
|
|
});
|
|
|
|
|
|
+ let eventRefreshSort: emitter.InnerEvent = { eventId: EventConstants.EVENT_PLAYLIST_REFRESH_SORT }
|
|
|
+ // 监听广播事件(通用设置配置更新)
|
|
|
+ emitter.on(eventRefreshSort, (eventData: emitter.EventData) => {
|
|
|
+ if(this.modeType ==4){
|
|
|
+ this.doSongListTask()//获取歌单信息
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
let eventSetting: emitter.InnerEvent = { eventId: EventConstants.EVENT_SETTING_UPDATE }
|
|
|
// 监听广播事件(通用设置配置更新)
|
|
|
emitter.on(eventSetting, (eventData: emitter.EventData) => {
|
|
|
@@ -904,6 +916,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{
|
|
|
@@ -1405,7 +1418,7 @@ export struct LocalMusic {
|
|
|
updateListData(mList: Array<VideoItem>, noSort?: boolean) {
|
|
|
|
|
|
animateTo({ duration: 666 }, () => {
|
|
|
- this.opacityItem = 0;
|
|
|
+ this.opacityItem = 0.5;
|
|
|
});
|
|
|
setTimeout(() => {
|
|
|
this.videoLocalList = mList;
|
|
|
@@ -1844,8 +1857,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;
|
|
|
}
|
|
|
@@ -3852,13 +3933,16 @@ export struct LocalMusic {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- itemMove(index: number, newIndex: number): void {
|
|
|
+ itemMove(index: number, newIndex: number): void {
|
|
|
if (newIndex < 0 || newIndex >= this.videoLocalList.length) {
|
|
|
return;
|
|
|
}
|
|
|
let tmp = this.videoLocalList.splice(index, 1);
|
|
|
this.videoLocalList.splice(newIndex, 0, tmp[0]);
|
|
|
this.dataSource.pushArrayData(this.videoLocalList)
|
|
|
+ if(this.modeType==4&&this.playlistTable){
|
|
|
+ updateAllSongsSortOrder(this.playlistTable, this.videoLocalList,this.currentSongListID)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -7343,7 +7427,7 @@ export struct LocalMusic {
|
|
|
|
|
|
}
|
|
|
|
|
|
- itemMoveSon(index: number, newIndex: number): void {
|
|
|
+ itemMoveSon(index: number, newIndex: number): void {
|
|
|
if (newIndex < 0 || newIndex >= this.songList.length) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -7351,6 +7435,9 @@ export struct LocalMusic {
|
|
|
this.songList.splice(newIndex, 0, tmp[0]);
|
|
|
this.sonDataSource.pushArrayData(this.songList)
|
|
|
this.curIndex = Utility.getIndexFromList(this.songList, this.videoUrl)
|
|
|
+ if(this.modeType==4&&this.playlistTable){
|
|
|
+ updateAllSongsSortOrder(this.playlistTable, this.songList,this.currentSongListID)
|
|
|
+ }
|
|
|
}
|
|
|
@Builder
|
|
|
PlayList() {
|
|
|
@@ -8649,8 +8736,8 @@ export struct LocalMusic {
|
|
|
Stack() {
|
|
|
|
|
|
Image(StrUtil.isEmpty(this.cover) ? this.imageLabel : this.cover)
|
|
|
- .height(62)
|
|
|
- .width(62)
|
|
|
+ .height(58)
|
|
|
+ .width(58)
|
|
|
.alt(this.imageLabel)
|
|
|
.borderRadius(8)
|
|
|
.clickEffect({ level: ClickEffectLevel.HEAVY })
|
|
|
@@ -8671,14 +8758,14 @@ export struct LocalMusic {
|
|
|
.maxLines(1)
|
|
|
.fontWeight(FontWeight.Bolder)
|
|
|
.fontColor(this.currentLyricColor)
|
|
|
- .margin({ left: this.currentLyricAlignMode === 0 ? 18 : 0 })
|
|
|
+ .margin({ left: this.currentLyricAlignMode === 0 ? 24 : 0 })
|
|
|
Row() {
|
|
|
Text(this.currentSong?.artist !== undefined ? this.currentSong?.artist : '')
|
|
|
.fontSize(13)
|
|
|
.fontWeight(FontWeight.Bold)
|
|
|
.padding({ top: 8 })
|
|
|
.fontColor(this.currentLyricColor)
|
|
|
- .margin({ left: this.currentLyricAlignMode === 0 ? 18 : 0 })
|
|
|
+ .margin({ left: this.currentLyricAlignMode === 0 ? 24 : 0 })
|
|
|
Blank()
|
|
|
|
|
|
}
|
|
|
@@ -9488,7 +9575,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)
|
|
|
@@ -11011,8 +11098,7 @@ export struct LocalMusic {
|
|
|
this.isShowMoreView = false
|
|
|
break;
|
|
|
case 20://AB循环
|
|
|
- this.isOpenAB = !this.isOpenAB;
|
|
|
- this.isABSheet = false
|
|
|
+ this.isABSheet = !this.isABSheet
|
|
|
break;
|
|
|
}
|
|
|
|