|
|
@@ -26,7 +26,7 @@ import { BusinessError, emitter } from '@kit.BasicServicesKit';
|
|
|
import { dataSharePredicates, uniformTypeDescriptor } from '@kit.ArkData';
|
|
|
import { BubbleBean } from '../viewmodel/BubbleBean';
|
|
|
import { PopupPosition, XPopup } from '@chinalike/popup';
|
|
|
-import { common } from '@kit.AbilityKit';
|
|
|
+import { common, ConfigurationConstant } from '@kit.AbilityKit';
|
|
|
import { AnimationHelper, DialogAction, DialogHelper } from '@pura/harmony-dialog';
|
|
|
import { fileIo, fileUri, picker } from '@kit.CoreFileKit';
|
|
|
import { CSJUtil } from '../common/util/CSJUtil';
|
|
|
@@ -165,7 +165,18 @@ export struct LocalMusic {
|
|
|
@Consume @Watch('onModeChange') modeType: number; // 0首页,1媒体库,2艺术家,3专辑
|
|
|
@State showSingleLyric: boolean = false
|
|
|
@State sortType: number = 4 //默认排序方式
|
|
|
- @Consume isDarkMode: boolean; // 消耗深色模式状态
|
|
|
+ @StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number =
|
|
|
+ ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
|
|
|
+
|
|
|
+ onColorModeChange() {
|
|
|
+ console.log('Heanup-当前模式:' + this.currentMode)
|
|
|
+ if (this.currentMode == ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT) {
|
|
|
+ //当前为浅色模式,资源初始化逻辑
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //当前为深色模式,资源初始化逻辑
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
onModeChange() {
|
|
|
if (this.modeType === 2 || this.modeType === 3) {
|
|
|
@@ -300,14 +311,12 @@ export struct LocalMusic {
|
|
|
.setLeftIconHeight(25)
|
|
|
.setTitleName('首页')
|
|
|
.setTitleFontSize(19)
|
|
|
- .setTitleFontColor($r('app.color.text_color'))
|
|
|
- // 根据深色模式状态动态设置标题栏背景色
|
|
|
- .setTitleBarBackground(this.isDarkMode ? '#121212' : '#FF4081')
|
|
|
+ .setTitleFontColor($r('app.color.text_color'))// 根据深色模式状态动态设置标题栏背景色
|
|
|
+ .setTitleBarBackground($r('app.color.title_bar_bg'))
|
|
|
.setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
|
|
|
.setRightTitleBackground($r('app.color.title_bar_bg'))
|
|
|
.setRightIcon($r('app.media.add'))
|
|
|
.setOnRightClickListener(() => {
|
|
|
-
|
|
|
this.showSheelDialog()
|
|
|
})
|
|
|
.setOnTitleClickListener(() => {
|
|
|
@@ -346,7 +355,7 @@ export struct LocalMusic {
|
|
|
|
|
|
// 组件生命周期
|
|
|
aboutToAppear() {
|
|
|
- this.sortType = PreferencesUtil.getNumberSync(SettingPage.SORT_TYPE, 4)
|
|
|
+ this.sortType = PreferencesUtil.getNumberSync(SettingPage.SORT_TYPE, 4)
|
|
|
Utility.getAppName(getContext(this)).then((appName: string) => {
|
|
|
this.appName = appName
|
|
|
})
|
|
|
@@ -451,7 +460,7 @@ export struct LocalMusic {
|
|
|
data1: this.context,
|
|
|
data2: this.rootPath,
|
|
|
data3: this.lockPath,
|
|
|
- data4: PreferencesUtil.getStringSync('COVER_API',''),
|
|
|
+ data4: PreferencesUtil.getStringSync('COVER_API', ''),
|
|
|
});
|
|
|
PreferencesUtil.putSync('isFirstApp', false)
|
|
|
} else {
|
|
|
@@ -860,16 +869,16 @@ export struct LocalMusic {
|
|
|
return mediaItems;
|
|
|
}
|
|
|
|
|
|
- updateListData(mList: Array<VideoItem>,noSort?:boolean) {
|
|
|
+ updateListData(mList: Array<VideoItem>, noSort?: boolean) {
|
|
|
|
|
|
animateTo({ duration: 888 }, () => {
|
|
|
this.opacityItem = 0;
|
|
|
});
|
|
|
setTimeout(() => {
|
|
|
this.videoLocalList = mList;
|
|
|
- if(!noSort){
|
|
|
- if(this.modeType===0||this.modeType===1){
|
|
|
- this.sortType = PreferencesUtil.getNumberSync(SettingPage.SORT_TYPE, 4)
|
|
|
+ if (!noSort) {
|
|
|
+ if (this.modeType === 0 || this.modeType === 1) {
|
|
|
+ this.sortType = PreferencesUtil.getNumberSync(SettingPage.SORT_TYPE, 4)
|
|
|
this.doSortType(this.sortType)
|
|
|
}
|
|
|
}
|
|
|
@@ -933,6 +942,7 @@ export struct LocalMusic {
|
|
|
let pup = XPopup.Builder()
|
|
|
.setPopupPosition(PopupPosition.BOTTOM)
|
|
|
.atView('pup_positon_music')
|
|
|
+ .setBackgroundColor($r('app.color.title_bar_bg'))
|
|
|
.asBubble(wrapBuilder(customPopupBuilder), dataBean)
|
|
|
.show()
|
|
|
|
|
|
@@ -969,7 +979,7 @@ export struct LocalMusic {
|
|
|
data1: this.context,
|
|
|
data2: this.rootPath,
|
|
|
data3: this.lockPath,
|
|
|
- data4: PreferencesUtil.getStringSync('COVER_API',''),
|
|
|
+ data4: PreferencesUtil.getStringSync('COVER_API', ''),
|
|
|
});
|
|
|
break
|
|
|
}
|
|
|
@@ -1043,22 +1053,23 @@ export struct LocalMusic {
|
|
|
transition: AnimationHelper.transitionInDown(555),
|
|
|
onAction: (index) => {
|
|
|
this.doSortType(index)
|
|
|
- this.updateListData(this.videoLocalList,true)
|
|
|
+ this.updateListData(this.videoLocalList, true)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- doSortType(index:number){
|
|
|
- switch (index){
|
|
|
+ doSortType(index: number) {
|
|
|
+ switch (index) {
|
|
|
case 0:
|
|
|
this.videoLocalList.sort((a: VideoItem, b: VideoItem) => {
|
|
|
// 类型排序优先级
|
|
|
const typeOrder = getTypeOrder(a.type) - getTypeOrder(b.type);
|
|
|
- if (typeOrder !== 0) return typeOrder;
|
|
|
+ if (typeOrder !== 0) {
|
|
|
+ return typeOrder;
|
|
|
+ }
|
|
|
|
|
|
// 处理艺术家可能为undefined的字符串比较
|
|
|
- const artistA = a.artist?.trim() || ''; // 可选添加 trim() 处理空格
|
|
|
+ const artistA = a.artist?.trim() || ''; // 可选添加 trim() 处理空格
|
|
|
const artistB = b.artist?.trim() || '';
|
|
|
return artistA.localeCompare(artistB);
|
|
|
});
|
|
|
@@ -1068,10 +1079,12 @@ export struct LocalMusic {
|
|
|
this.videoLocalList.sort((a: VideoItem, b: VideoItem) => {
|
|
|
// 类型排序优先级
|
|
|
const typeOrder = getTypeOrder(a.type) - getTypeOrder(b.type);
|
|
|
- if (typeOrder !== 0) return typeOrder;
|
|
|
+ if (typeOrder !== 0) {
|
|
|
+ return typeOrder;
|
|
|
+ }
|
|
|
|
|
|
// 处理艺术家可能为undefined的字符串比较
|
|
|
- const artistA = a.artist?.trim() || ''; // 可选添加 trim() 处理空格
|
|
|
+ const artistA = a.artist?.trim() || ''; // 可选添加 trim() 处理空格
|
|
|
const artistB = b.artist?.trim() || '';
|
|
|
return artistB.localeCompare(artistA);
|
|
|
});
|
|
|
@@ -1080,10 +1093,12 @@ export struct LocalMusic {
|
|
|
this.videoLocalList.sort((a: VideoItem, b: VideoItem) => {
|
|
|
// 类型排序优先级
|
|
|
const typeOrder = getTypeOrder(a.type) - getTypeOrder(b.type);
|
|
|
- if (typeOrder !== 0) return typeOrder;
|
|
|
+ if (typeOrder !== 0) {
|
|
|
+ return typeOrder;
|
|
|
+ }
|
|
|
|
|
|
// 处理专辑可能为undefined的字符串比较
|
|
|
- const albumA = a.album?.trim() || ''; // 可选添加 trim() 处理空格
|
|
|
+ const albumA = a.album?.trim() || ''; // 可选添加 trim() 处理空格
|
|
|
const albumB = b.album?.trim() || '';
|
|
|
return albumA.localeCompare(albumB);
|
|
|
});
|
|
|
@@ -1093,10 +1108,12 @@ export struct LocalMusic {
|
|
|
this.videoLocalList.sort((a: VideoItem, b: VideoItem) => {
|
|
|
// 类型排序优先级
|
|
|
const typeOrder = getTypeOrder(a.type) - getTypeOrder(b.type);
|
|
|
- if (typeOrder !== 0) return typeOrder;
|
|
|
+ if (typeOrder !== 0) {
|
|
|
+ return typeOrder;
|
|
|
+ }
|
|
|
|
|
|
// 处理专辑可能为undefined的字符串比较
|
|
|
- const albumA = a.album?.trim() || ''; // 可选添加 trim() 处理空格
|
|
|
+ const albumA = a.album?.trim() || ''; // 可选添加 trim() 处理空格
|
|
|
const albumB = b.album?.trim() || '';
|
|
|
return albumB.localeCompare(albumA);
|
|
|
});
|
|
|
@@ -2149,13 +2166,15 @@ export struct LocalMusic {
|
|
|
duration: 555,
|
|
|
curve: 'Linear',
|
|
|
})
|
|
|
- .fontColor(this.currentSong?.filePath === item.filePath ? $r('app.color.title_bar_bg') : $r('app.color.text_color'))
|
|
|
+ .fontColor(this.currentSong?.filePath === item.filePath ? $r('app.color.title_bar_bg') :
|
|
|
+ $r('app.color.text_color'))
|
|
|
.margin({ left: 10 })
|
|
|
Row() {
|
|
|
Text(StrUtil.isEmpty(item.artist) ? item.cTime : item.artist + ' ' + item?.album)
|
|
|
.fontSize(11)
|
|
|
.padding({ top: 8 })
|
|
|
- .fontColor(this.currentSong?.filePath === item.filePath ? $r('app.color.title_bar_bg') : $r('app.color.text_color'))
|
|
|
+ .fontColor(this.currentSong?.filePath === item.filePath ? $r('app.color.title_bar_bg') :
|
|
|
+ $r('app.color.text_color'))
|
|
|
.margin({ left: 10 })
|
|
|
Blank()
|
|
|
Text(item.size)
|
|
|
@@ -3580,7 +3599,8 @@ export struct LocalMusic {
|
|
|
// 文字描述区域
|
|
|
Text(this.getDisplayText(minutes))
|
|
|
.fontSize(15)
|
|
|
- .fontColor(minutes === this.selectedMinutes ? $r('app.color.title_bar_bg') : $r('app.color.text_color'))// 选中态颜色变化
|
|
|
+ .fontColor(minutes === this.selectedMinutes ? $r('app.color.title_bar_bg') :
|
|
|
+ $r('app.color.text_color'))// 选中态颜色变化
|
|
|
.textAlign(TextAlign.Start)
|
|
|
.layoutWeight(1); // 占据剩余空间
|
|
|
|
|
|
@@ -4306,9 +4326,9 @@ export struct LocalMusic {
|
|
|
let jiaMilyricPath = lyricPath.substring(0, lyricPath.lastIndexOf('.')) + '.lrcc'
|
|
|
LogUtil.debug("onecold lyricPath =" + lyricPath)
|
|
|
|
|
|
- const neiqianLrc = LrcParser.getLyrics(this.videoUrl);//获取内嵌歌词
|
|
|
- if(StrUtil.isNotEmpty(neiqianLrc)&&!isToast){
|
|
|
- LogUtil.debug("onecold 找到内嵌歌词 neiqianLrc =" + neiqianLrc )
|
|
|
+ const neiqianLrc = LrcParser.getLyrics(this.videoUrl); //获取内嵌歌词
|
|
|
+ if (StrUtil.isNotEmpty(neiqianLrc) && !isToast) {
|
|
|
+ LogUtil.debug("onecold 找到内嵌歌词 neiqianLrc =" + neiqianLrc)
|
|
|
//赋值给this.lyricContent,播控中心才可以显示歌词
|
|
|
this.lyricContent = neiqianLrc
|
|
|
// 将文件内容按行分割成字符串数组
|
|
|
@@ -4322,8 +4342,6 @@ export struct LocalMusic {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
if (isToast || ((!FileUtil.accessSync(lyricPath) && !FileUtil.accessSync(jiaMilyricPath))
|
|
|
&& !Utility.isVideoByExtension(this.videoUrl))) {
|
|
|
if (this.currentSong !== undefined) {
|
|
|
@@ -4579,8 +4597,6 @@ export struct LocalMusic {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// 定义开始旋转的方法
|
|
|
// 定时器用于一百毫秒执行一次旋转角度
|
|
|
@State timer: number = 0
|
|
|
@@ -5771,8 +5787,8 @@ export struct LocalMusic {
|
|
|
{ value: '3x' }])
|
|
|
.font({ size: 16, weight: FontWeight.Medium })
|
|
|
.fontColor($r('sys.color.white'))
|
|
|
- .margin({left:25})
|
|
|
- .visibility(more.id===1?Visibility.Visible:Visibility.None)
|
|
|
+ .margin({ left: 25 })
|
|
|
+ .visibility(more.id === 1 ? Visibility.Visible : Visibility.None)
|
|
|
.selected(CommonConstants.video_speed_list.indexOf(this.playSpeed))
|
|
|
.value(Utility.optimizedFormat(this.playSpeed))
|
|
|
.onSelect(async (_index: number, text?: string | undefined) => {
|
|
|
@@ -5781,7 +5797,7 @@ export struct LocalMusic {
|
|
|
speed = 1;
|
|
|
}
|
|
|
this.playSpeed = speed
|
|
|
- this.mIjkMediaPlayer.setSpeed(this.playSpeed+'f');
|
|
|
+ this.mIjkMediaPlayer.setSpeed(this.playSpeed + 'f');
|
|
|
})
|
|
|
Slider({
|
|
|
value: this.volume,
|
|
|
@@ -6467,7 +6483,7 @@ export struct LocalMusic {
|
|
|
this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_timeout", "10000000");
|
|
|
// 变速播放
|
|
|
this.mIjkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "soundtouch", "1");
|
|
|
- this.mIjkMediaPlayer.setSpeed(this.playSpeed+'f');
|
|
|
+ this.mIjkMediaPlayer.setSpeed(this.playSpeed + 'f');
|
|
|
let Speed = this.mIjkMediaPlayer.getSpeed()
|
|
|
LogUtils.getInstance().LOGI('getSpeed--' + Speed)
|
|
|
//是否开启循环播放
|