|
@@ -1,5 +1,6 @@
|
|
|
import TitleBar from './TitleBar'
|
|
import TitleBar from './TitleBar'
|
|
|
-import { Animator, curves, display, PromptAction, promptAction, router, SymbolGlyphModifier, window } from '@kit.ArkUI';
|
|
|
|
|
|
|
+import { Animator,
|
|
|
|
|
+ curves, display, PromptAction, promptAction, router, SymbolGlyphModifier, window } from '@kit.ArkUI';
|
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
|
import {
|
|
import {
|
|
|
AppUtil,
|
|
AppUtil,
|
|
@@ -84,6 +85,7 @@ import { deviceInfo } from '@kit.BasicServicesKit';
|
|
|
import { HSBColorPicker, HSBColorPickerLayout } from '@keke/color-picker'
|
|
import { HSBColorPicker, HSBColorPickerLayout } from '@keke/color-picker'
|
|
|
import { DEBUG } from 'BuildProfile';
|
|
import { DEBUG } from 'BuildProfile';
|
|
|
import { LrcParser } from '@sgaolei/lrc_parser';
|
|
import { LrcParser } from '@sgaolei/lrc_parser';
|
|
|
|
|
+import app, { AppResponse } from '@system.app';
|
|
|
|
|
|
|
|
const TAG = 'LocalMusic';
|
|
const TAG = 'LocalMusic';
|
|
|
|
|
|
|
@@ -128,7 +130,7 @@ interface GeneratedObjectLiteralInterface_1 {
|
|
|
// DRM资源,需要配置支持的DRM类型, 以chinaDRM为例。
|
|
// DRM资源,需要配置支持的DRM类型, 以chinaDRM为例。
|
|
|
drmScheme: string;
|
|
drmScheme: string;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+const ITEM_HEIGHT: number = 58; // 列表项高度
|
|
|
//功能强大的音乐播放器
|
|
//功能强大的音乐播放器
|
|
|
@Preview
|
|
@Preview
|
|
|
@Component
|
|
@Component
|
|
@@ -171,10 +173,20 @@ export struct LocalMusic {
|
|
|
@State isCustomizeBg: boolean = false //自定义背景界面
|
|
@State isCustomizeBg: boolean = false //自定义背景界面
|
|
|
@State isGridMusic: boolean = false //是否网格布局
|
|
@State isGridMusic: boolean = false //是否网格布局
|
|
|
@State isScrollHide: boolean = false //是否滚动隐藏
|
|
@State isScrollHide: boolean = false //是否滚动隐藏
|
|
|
|
|
+ @State isSameTimePlay: boolean = false //是否和其他app同时播放
|
|
|
@State customizeBgPath: string | undefined = '';
|
|
@State customizeBgPath: string | undefined = '';
|
|
|
@State isDarkMode: boolean = false
|
|
@State isDarkMode: boolean = false
|
|
|
@State lyricTextWeight: number = 400
|
|
@State lyricTextWeight: number = 400
|
|
|
@State currentSwiperIndex: number = 0
|
|
@State currentSwiperIndex: number = 0
|
|
|
|
|
+ @State blurValue: number = 0 //背景模糊
|
|
|
|
|
+ @State bgBrightness: number = 0 //背景亮度
|
|
|
|
|
+ private listScroller: ListScroller = new ListScroller()
|
|
|
|
|
+ private listArea: Area = {
|
|
|
|
|
+ width: 0,
|
|
|
|
|
+ height: 0,
|
|
|
|
|
+ position: {},
|
|
|
|
|
+ globalPosition: {}
|
|
|
|
|
+ }
|
|
|
@StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number =
|
|
@StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number =
|
|
|
ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
|
|
ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
|
|
|
|
|
|
|
@@ -362,22 +374,7 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
// 组件生命周期
|
|
// 组件生命周期
|
|
|
aboutToAppear() {
|
|
aboutToAppear() {
|
|
|
- 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.isGridMusic = PreferencesUtil.getBooleanSync(SettingPage.IS_GRID_MUSIC, false)
|
|
|
|
|
- this.isScrollHide = PreferencesUtil.getBooleanSync(SettingPage.IS_SCROLL_HIDE, false)
|
|
|
|
|
- if(this.isCustomizeBg){
|
|
|
|
|
- this.titleBarModel.setRightTitleStateNormalStyleColor(Color.Transparent)
|
|
|
|
|
- this.titleBarModel.setTitleBarBackground(Color.Transparent)
|
|
|
|
|
- this.titleBarModel.setTitleBarBottomLineColor(Color.Transparent)
|
|
|
|
|
- this.titleBarModel.setLeftTitleStateNormalStyleColor(Color.Transparent)
|
|
|
|
|
-
|
|
|
|
|
- }else{
|
|
|
|
|
- this.titleBarModel.setTitleBarBackground($r('app.color.title_bar_bg'))
|
|
|
|
|
- this.titleBarModel.setTitleBarBottomLineColor($r('app.color.title_bar_bg'))
|
|
|
|
|
- // this.titleBarModel .setRightTitleBackground($r('app.color.title_bar_bg'))
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.initSetting()
|
|
|
|
|
|
|
|
Utility.getAppName(getContext(this)).then((appName: string) => {
|
|
Utility.getAppName(getContext(this)).then((appName: string) => {
|
|
|
this.appName = appName
|
|
this.appName = appName
|
|
@@ -385,11 +382,6 @@ export struct LocalMusic {
|
|
|
this.packName = AppUtil.getBundleName()
|
|
this.packName = AppUtil.getBundleName()
|
|
|
this.loadCacheFromStorage(); // 加载缓存
|
|
this.loadCacheFromStorage(); // 加载缓存
|
|
|
|
|
|
|
|
- this.isSavePlayMode = PreferencesUtil.getBooleanSync(SettingPage.iS_SAVE_PLAY_MODE, true)
|
|
|
|
|
- if (this.isSavePlayMode) {
|
|
|
|
|
- this.playType = PreferencesUtil.getNumberSync('musicPlayType', 0)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
this.historyList = PreferencesUtil.getSync(LocalMusic.HISTORY_MUSIC, this.historyList) as Array<VideoItem>
|
|
this.historyList = PreferencesUtil.getSync(LocalMusic.HISTORY_MUSIC, this.historyList) as Array<VideoItem>
|
|
|
|
|
|
|
|
this.mkDownLoadDir()
|
|
this.mkDownLoadDir()
|
|
@@ -426,7 +418,8 @@ export struct LocalMusic {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
let event: Callback<InterruptEvent> = (event) => {
|
|
let event: Callback<InterruptEvent> = (event) => {
|
|
|
- LogUtils.getInstance().LOGI(`event: ${JSON.stringify(event)}`);
|
|
|
|
|
|
|
+ LogUtils.getInstance().LOGI(`onecold 与其他应用音频冲突 被截断点event: ${JSON.stringify(event)}`);
|
|
|
|
|
+ this.savePlaybackPosition()
|
|
|
if (event.hintType === InterruptHintType.INTERRUPT_HINT_PAUSE) {
|
|
if (event.hintType === InterruptHintType.INTERRUPT_HINT_PAUSE) {
|
|
|
this.pause();
|
|
this.pause();
|
|
|
} else if (event.hintType === InterruptHintType.INTERRUPT_HINT_RESUME) {
|
|
} else if (event.hintType === InterruptHintType.INTERRUPT_HINT_RESUME) {
|
|
@@ -479,12 +472,20 @@ export struct LocalMusic {
|
|
|
context.getApplicationContext().setColorMode(colorMode)
|
|
context.getApplicationContext().setColorMode(colorMode)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- doChangeSetting(){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ initSetting(){
|
|
|
this.sortType = PreferencesUtil.getNumberSync(SettingPage.SORT_TYPE, 4)
|
|
this.sortType = PreferencesUtil.getNumberSync(SettingPage.SORT_TYPE, 4)
|
|
|
this.isCustomizeBg = PreferencesUtil.getBooleanSync(SettingPage.IS_CUSTOMIZE_BG, false)
|
|
this.isCustomizeBg = PreferencesUtil.getBooleanSync(SettingPage.IS_CUSTOMIZE_BG, false)
|
|
|
this.customizeBgPath = PreferencesUtil.getStringSync(SettingPage.IS_CUSTOMIZE_BG_PATH, '')
|
|
this.customizeBgPath = PreferencesUtil.getStringSync(SettingPage.IS_CUSTOMIZE_BG_PATH, '')
|
|
|
this.isGridMusic = PreferencesUtil.getBooleanSync(SettingPage.IS_GRID_MUSIC, false)
|
|
this.isGridMusic = PreferencesUtil.getBooleanSync(SettingPage.IS_GRID_MUSIC, false)
|
|
|
this.isScrollHide = PreferencesUtil.getBooleanSync(SettingPage.IS_SCROLL_HIDE, false)
|
|
this.isScrollHide = PreferencesUtil.getBooleanSync(SettingPage.IS_SCROLL_HIDE, false)
|
|
|
|
|
+ this.isSameTimePlay = PreferencesUtil.getBooleanSync(SettingPage.IS_SAMETIME_PLAY, false)
|
|
|
|
|
+ this.isSavePlayMode = PreferencesUtil.getBooleanSync(SettingPage.iS_SAVE_PLAY_MODE, true)
|
|
|
|
|
+ this.blurValue = PreferencesUtil.getNumberSync(SettingPage.CUSTOMIZE_BG_BLUR, 0)
|
|
|
|
|
+ this.bgBrightness = PreferencesUtil.getNumberSync(SettingPage.BG_BRIGHTNESS, 0)
|
|
|
|
|
+ if (this.isSavePlayMode) {
|
|
|
|
|
+ this.playType = PreferencesUtil.getNumberSync('musicPlayType', 0)
|
|
|
|
|
+ }
|
|
|
if(this.isCustomizeBg){
|
|
if(this.isCustomizeBg){
|
|
|
this.titleBarModel.setRightTitleStateNormalStyleColor(Color.Transparent)
|
|
this.titleBarModel.setRightTitleStateNormalStyleColor(Color.Transparent)
|
|
|
this.titleBarModel.setTitleBarBackground(Color.Transparent)
|
|
this.titleBarModel.setTitleBarBackground(Color.Transparent)
|
|
@@ -496,7 +497,10 @@ export struct LocalMusic {
|
|
|
this.titleBarModel.setRightTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
|
|
this.titleBarModel.setRightTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
|
|
|
this.titleBarModel.setLeftTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
|
|
this.titleBarModel.setLeftTitleStateNormalStyleColor($r('app.color.title_bar_bg'))
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ doChangeSetting(){
|
|
|
|
|
+ this.initSetting()
|
|
|
this.doUpdateData()
|
|
this.doUpdateData()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -511,6 +515,9 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onPageShow() {
|
|
onPageShow() {
|
|
|
|
|
+ app.setImageCacheCount(100);
|
|
|
|
|
+ // 设置解码前图片数据内存缓存上限为100MB (100MB=100*1024*1024B=104857600B)
|
|
|
|
|
+ app.setImageRawDataCacheSize(104857600);
|
|
|
Logger.info('onecold onPageShow currentBreakpoint= ' + this.currentBreakpoint)
|
|
Logger.info('onecold onPageShow currentBreakpoint= ' + this.currentBreakpoint)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1878,6 +1885,8 @@ export struct LocalMusic {
|
|
|
.backgroundImage(this.isCustomizeBg?this.customizeBgPath:$r('app.color.bottom_control_background'))
|
|
.backgroundImage(this.isCustomizeBg?this.customizeBgPath:$r('app.color.bottom_control_background'))
|
|
|
.backgroundImageSize(this.isCoverOpacity()?{width:'100%'}:{ height: '100%'})
|
|
.backgroundImageSize(this.isCoverOpacity()?{width:'100%'}:{ height: '100%'})
|
|
|
.backgroundImagePosition(Alignment.Center)
|
|
.backgroundImagePosition(Alignment.Center)
|
|
|
|
|
+ .backdropBlur(this.blurValue)
|
|
|
|
|
+ .backgroundBrightness({rate:this.isCustomizeBg?0.1:0,lightUpDegree:this.bgBrightness})
|
|
|
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
|
|
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -2187,7 +2196,7 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- .height(58)
|
|
|
|
|
|
|
+ .height(ITEM_HEIGHT)
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.visibility(this.isShowDir(item.name)?Visibility.Visible:Visibility.None)
|
|
.visibility(this.isShowDir(item.name)?Visibility.Visible:Visibility.None)
|
|
|
.opacity(this.opacityItem) // 绑定透明度
|
|
.opacity(this.opacityItem) // 绑定透明度
|
|
@@ -2304,7 +2313,7 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
- .height(58)
|
|
|
|
|
|
|
+ .height(ITEM_HEIGHT)
|
|
|
.justifyContent(FlexAlign.SpaceBetween)
|
|
.justifyContent(FlexAlign.SpaceBetween)
|
|
|
.stateStyles({
|
|
.stateStyles({
|
|
|
pressed: { opacity: 0.6 } // 按压反馈
|
|
pressed: { opacity: 0.6 } // 按压反馈
|
|
@@ -2794,6 +2803,8 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private scroller: Scroller = new Scroller();
|
|
private scroller: Scroller = new Scroller();
|
|
|
|
|
+ @State startIndex:number = 0
|
|
|
|
|
+ @State endIndex:number = 0
|
|
|
@Builder
|
|
@Builder
|
|
|
getGridView(){
|
|
getGridView(){
|
|
|
|
|
|
|
@@ -2887,6 +2898,11 @@ export struct LocalMusic {
|
|
|
.rowsGap(12)
|
|
.rowsGap(12)
|
|
|
.visibility(this.isGridMusic?Visibility.Visible:Visibility.None)
|
|
.visibility(this.isGridMusic?Visibility.Visible:Visibility.None)
|
|
|
.enableScrollInteraction(true)
|
|
.enableScrollInteraction(true)
|
|
|
|
|
+ // 滚轴滑动,记录下滑动时的起始位置和终点位置
|
|
|
|
|
+ .onScrollIndex((start: number, end: number) => {
|
|
|
|
|
+ this.startIndex = start
|
|
|
|
|
+ this.endIndex = end
|
|
|
|
|
+ })
|
|
|
.onScrollFrameBegin((offset: number) => {
|
|
.onScrollFrameBegin((offset: number) => {
|
|
|
//滚动小屏幕 比如puraX外屏和手机横屏可以隐藏bottomBarHeight topBarHeight
|
|
//滚动小屏幕 比如puraX外屏和手机横屏可以隐藏bottomBarHeight topBarHeight
|
|
|
if(this.isPhoneLan()){
|
|
if(this.isPhoneLan()){
|
|
@@ -3128,11 +3144,11 @@ export struct LocalMusic {
|
|
|
.height(item.type === CommonConstants.TYPE_IS_DIR ?'22%':'40%')
|
|
.height(item.type === CommonConstants.TYPE_IS_DIR ?'22%':'40%')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ private listMaxScrollOffsetY: number = 0
|
|
|
@Builder
|
|
@Builder
|
|
|
getListView() {
|
|
getListView() {
|
|
|
|
|
|
|
|
- List() {
|
|
|
|
|
|
|
+ List({ scroller: this.listScroller }) {
|
|
|
LazyForEach(this.dataSource, (item: VideoItem, index: number) => {
|
|
LazyForEach(this.dataSource, (item: VideoItem, index: number) => {
|
|
|
ListItem() {
|
|
ListItem() {
|
|
|
Column() {
|
|
Column() {
|
|
@@ -3251,7 +3267,23 @@ export struct LocalMusic {
|
|
|
this.itemMove(indexA, indexA - 1);
|
|
this.itemMove(indexA, indexA - 1);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ let curListOffset = this.listScroller.currentOffset()
|
|
|
|
|
+ // 获取手指信息
|
|
|
|
|
+ let fingerInfo = event.fingerList[0]
|
|
|
|
|
+ let clickPercentY =
|
|
|
|
|
+ (fingerInfo.globalY - Number(this.listArea.globalPosition.y)) / Number(this.listArea.height)
|
|
|
|
|
+ if (clickPercentY > 0.8 && !this.listScroller.isAtEnd()) {
|
|
|
|
|
+ let scrollVelocity = clickPercentY > 0.9 ? 4 : 2
|
|
|
|
|
+ if (this.listMaxScrollOffsetY - curListOffset.yOffset > scrollVelocity + 5) {
|
|
|
|
|
+ this.listScroller.scrollTo({xOffset: 0, yOffset: curListOffset.yOffset += scrollVelocity})
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (clickPercentY < 0.2 && curListOffset.yOffset >= 0) {
|
|
|
|
|
+ let scrollVelocity = clickPercentY < 0.1 ? 4 : 2
|
|
|
|
|
+ if (curListOffset.yOffset > scrollVelocity + 5) {
|
|
|
|
|
+ this.listScroller.scrollTo({xOffset: 0, yOffset: curListOffset.yOffset -= scrollVelocity})
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
.onActionEnd((event: GestureEvent) => {
|
|
.onActionEnd((event: GestureEvent) => {
|
|
@@ -3306,6 +3338,10 @@ export struct LocalMusic {
|
|
|
xxl: 20
|
|
xxl: 20
|
|
|
}).getValue(this.currentBreakpoint)
|
|
}).getValue(this.currentBreakpoint)
|
|
|
)
|
|
)
|
|
|
|
|
+ .onAreaChange((oldValue: Area, newValue: Area) => {
|
|
|
|
|
+ this.listArea = newValue
|
|
|
|
|
+ this.listMaxScrollOffsetY = this.videoLocalList.length * (ITEM_HEIGHT) - 10
|
|
|
|
|
+ })
|
|
|
.onScrollFrameBegin((offset: number) => {
|
|
.onScrollFrameBegin((offset: number) => {
|
|
|
|
|
|
|
|
//滚动小屏幕 比如puraX外屏和手机横屏可以隐藏bottomBarHeight topBarHeight
|
|
//滚动小屏幕 比如puraX外屏和手机横屏可以隐藏bottomBarHeight topBarHeight
|