|
@@ -343,6 +343,7 @@ export enum SortMode {
|
|
|
@Preview
|
|
@Preview
|
|
|
@Component
|
|
@Component
|
|
|
export struct LocalMusic {
|
|
export struct LocalMusic {
|
|
|
|
|
+ @State bluetoothDisconnectPause: boolean = false // 蓝牙设备断开暂停
|
|
|
@State showFindLocation: boolean = true
|
|
@State showFindLocation: boolean = true
|
|
|
@StorageProp("EnablePointLight") enablePointLight: boolean = true
|
|
@StorageProp("EnablePointLight") enablePointLight: boolean = true
|
|
|
@State showSimple: boolean = true//开启沉浸模式
|
|
@State showSimple: boolean = true//开启沉浸模式
|
|
@@ -1039,7 +1040,7 @@ export struct LocalMusic {
|
|
|
console.info(`onecold device descriptor size : ${deviceChanged.deviceDescriptors.length}`);
|
|
console.info(`onecold device descriptor size : ${deviceChanged.deviceDescriptors.length}`);
|
|
|
console.info(`onecold device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceRole}`); // 设备角色。
|
|
console.info(`onecold device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceRole}`); // 设备角色。
|
|
|
console.info(`onecold device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceType}`);
|
|
console.info(`onecold device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceType}`);
|
|
|
- if(deviceChanged.type==1&&deviceChanged.deviceDescriptors[0].deviceRole==2&&
|
|
|
|
|
|
|
+ if(this.bluetoothDisconnectPause&&deviceChanged.type==1&&deviceChanged.deviceDescriptors[0].deviceRole==2&&
|
|
|
(deviceChanged.deviceDescriptors[0].deviceType==8)){
|
|
(deviceChanged.deviceDescriptors[0].deviceType==8)){
|
|
|
console.info('heanup onecold 蓝牙音响断开, 暂停播放')
|
|
console.info('heanup onecold 蓝牙音响断开, 暂停播放')
|
|
|
this.pause();
|
|
this.pause();
|
|
@@ -1206,6 +1207,7 @@ export struct LocalMusic {
|
|
|
context.getApplicationContext().setColorMode(colorMode)
|
|
context.getApplicationContext().setColorMode(colorMode)
|
|
|
}
|
|
}
|
|
|
initSetting() {
|
|
initSetting() {
|
|
|
|
|
+ this.bluetoothDisconnectPause = PreferencesUtil.getBooleanSync(SettingPage.BLUETOOTH_DISCONNECT_PAUSE, false)
|
|
|
this.isShowSpectrum = PreferencesUtil.getBooleanSync('isShowSpectrum', false)
|
|
this.isShowSpectrum = PreferencesUtil.getBooleanSync('isShowSpectrum', false)
|
|
|
this.spectrumModeIndex = PreferencesUtil.getNumberSync('spectrumModeIndex', 0)
|
|
this.spectrumModeIndex = PreferencesUtil.getNumberSync('spectrumModeIndex', 0)
|
|
|
this.enablePointLight = PreferencesUtil.getBooleanSync('enablePointLight', true)
|
|
this.enablePointLight = PreferencesUtil.getBooleanSync('enablePointLight', true)
|
|
@@ -9650,52 +9652,73 @@ export struct LocalMusic {
|
|
|
PanGesture(this.panOption)
|
|
PanGesture(this.panOption)
|
|
|
.onActionUpdate((event?: GestureEvent) => {
|
|
.onActionUpdate((event?: GestureEvent) => {
|
|
|
if (event) {
|
|
if (event) {
|
|
|
- // 只允许向下滑动,向上滑动时限制为0
|
|
|
|
|
- this.translateY = Math.max(0, event.offsetY);
|
|
|
|
|
|
|
+ // 判断滑动方向
|
|
|
|
|
+ const offsetY = event.offsetY ?? 0;
|
|
|
|
|
+ const isSwipeUp = offsetY < 0;
|
|
|
|
|
|
|
|
- this.getUIContext().animateTo({
|
|
|
|
|
- duration: 500,
|
|
|
|
|
- curve: Curve.Sharp
|
|
|
|
|
- }, () => {
|
|
|
|
|
- this.scaleValueImage = Math.min(1, Math.max(0.38, 1 - event.offsetY / 500));
|
|
|
|
|
- console.info('onecold scaleValueImage:', this.scaleValueImage)
|
|
|
|
|
|
|
+ if (isSwipeUp) {
|
|
|
|
|
+ // 向上滑动:不应用位移动画,保持 translateY = 0
|
|
|
|
|
+ this.translateY = 0;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 向下滑动:应用位移动画
|
|
|
|
|
+ this.translateY = offsetY;
|
|
|
|
|
|
|
|
- this.scaleValueText =Math.min(1, Math.max(0.6, 1 - event.offsetY / 700));
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // 向下滑动时的缩放效果
|
|
|
|
|
+ this.getUIContext().animateTo({
|
|
|
|
|
+ duration: 500,
|
|
|
|
|
+ curve: Curve.Sharp
|
|
|
|
|
+ }, () => {
|
|
|
|
|
+ this.scaleValueImage = Math.min(1, Math.max(0.38, 1 - this.translateY / 500));
|
|
|
|
|
+ console.info('onecold scaleValueImage:', this.scaleValueImage)
|
|
|
|
|
+ this.scaleValueText = Math.min(1, Math.max(0.6, 1 - this.translateY / 700));
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
.onActionEnd((event?: GestureEvent) => {
|
|
.onActionEnd((event?: GestureEvent) => {
|
|
|
- // 使用更低的阈值和滑动速度判断
|
|
|
|
|
- const minDistance = 300; // 最小滑动距离 100vp
|
|
|
|
|
|
|
+ // 判断滑动方向
|
|
|
|
|
+ const offsetY = event?.offsetY ?? 0;
|
|
|
|
|
+ const isSwipeUp = offsetY < 0;
|
|
|
|
|
+ const minDistance = 300; // 最小滑动距离
|
|
|
const minVelocity = 500; // 最小滑动速度
|
|
const minVelocity = 500; // 最小滑动速度
|
|
|
|
|
+ const velocity = event?.velocityY ?? 0;
|
|
|
|
|
|
|
|
- // 获取滑动速度(如果可用)
|
|
|
|
|
- const velocity = event?.velocityY || 0;
|
|
|
|
|
-
|
|
|
|
|
- // 判断是否应该关闭:距离足够 或者 速度足够快
|
|
|
|
|
- const shouldClose = this.translateY > minDistance || velocity > minVelocity;
|
|
|
|
|
-
|
|
|
|
|
- if (shouldClose) {
|
|
|
|
|
- // 添加关闭动画
|
|
|
|
|
- this.getUIContext().animateTo({
|
|
|
|
|
- duration: 600,
|
|
|
|
|
- curve: Curve.Friction
|
|
|
|
|
- }, () => {
|
|
|
|
|
- this.isShowPlay = false;
|
|
|
|
|
- this.scaleValueImage = 1
|
|
|
|
|
- this.scaleValueText = 1
|
|
|
|
|
- this.translateY = 0;
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if (isSwipeUp) {
|
|
|
|
|
+ // 向上滑动:切换下一首
|
|
|
|
|
+ const shouldSwitch = Math.abs(offsetY) > minDistance || Math.abs(velocity) > minVelocity;
|
|
|
|
|
+
|
|
|
|
|
+ if (shouldSwitch) {
|
|
|
|
|
+ // 直接切换下一首,无需动画(因为界面没有移动)
|
|
|
|
|
+ this.playNext().catch(() => {
|
|
|
|
|
+ Logger.error('heanup MusicPlayBuilder', '向上滑动切换下一首失败');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- // 回弹动画
|
|
|
|
|
- this.getUIContext().animateTo({
|
|
|
|
|
- duration: 600,
|
|
|
|
|
- curve: Curve.Friction
|
|
|
|
|
- }, () => {
|
|
|
|
|
- this.scaleValueImage = 1
|
|
|
|
|
- this.scaleValueText = 1
|
|
|
|
|
- this.translateY = 0;
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // 向下滑动:关闭播放页
|
|
|
|
|
+ const shouldClose = this.translateY > minDistance || velocity > minVelocity;
|
|
|
|
|
+
|
|
|
|
|
+ if (shouldClose) {
|
|
|
|
|
+ // 添加关闭动画
|
|
|
|
|
+ this.getUIContext().animateTo({
|
|
|
|
|
+ duration: 600,
|
|
|
|
|
+ curve: Curve.Friction
|
|
|
|
|
+ }, () => {
|
|
|
|
|
+ this.isShowPlay = false;
|
|
|
|
|
+ this.scaleValueImage = 1
|
|
|
|
|
+ this.scaleValueText = 1
|
|
|
|
|
+ this.translateY = 0;
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 回弹动画
|
|
|
|
|
+ this.getUIContext().animateTo({
|
|
|
|
|
+ duration: 600,
|
|
|
|
|
+ curve: Curve.Friction
|
|
|
|
|
+ }, () => {
|
|
|
|
|
+ this.scaleValueImage = 1
|
|
|
|
|
+ this.scaleValueText = 1
|
|
|
|
|
+ this.translateY = 0;
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
)
|
|
)
|
|
@@ -15357,7 +15380,7 @@ export struct LocalMusic {
|
|
|
isVisible: this.currentSwiperIndex === 0,
|
|
isVisible: this.currentSwiperIndex === 0,
|
|
|
isPlaying: this.CONTROL_PlayStatus === PlayStatus.PLAY
|
|
isPlaying: this.CONTROL_PlayStatus === PlayStatus.PLAY
|
|
|
})
|
|
})
|
|
|
- .width( '84%')
|
|
|
|
|
|
|
+ .width( '83%')
|
|
|
.height(this.isCoverOpacity() ? 80 : 100)
|
|
.height(this.isCoverOpacity() ? 80 : 100)
|
|
|
.margin({bottom: 3 })
|
|
.margin({bottom: 3 })
|
|
|
.clip(true)
|
|
.clip(true)
|