|
@@ -46,6 +46,7 @@ import {
|
|
|
ToastUtil
|
|
ToastUtil
|
|
|
} from '@pura/harmony-utils';
|
|
} from '@pura/harmony-utils';
|
|
|
import { imagePathToPixelMap } from '../common/util/CommUtils';
|
|
import { imagePathToPixelMap } from '../common/util/CommUtils';
|
|
|
|
|
+import LyricUtil from '../common/util/LyricUtil';
|
|
|
import { unifiedDataChannel, uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData';
|
|
import { unifiedDataChannel, uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData';
|
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
|
import { BaiduConstants } from '../common/constants/BaiduConstants';
|
|
import { BaiduConstants } from '../common/constants/BaiduConstants';
|
|
@@ -104,7 +105,6 @@ import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
|
import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
|
import MediaTable, { PageQueryOptions, PageQueryResult, RandomSongQueryOptions } from '../common/util/MediaTable';
|
|
import MediaTable, { PageQueryOptions, PageQueryResult, RandomSongQueryOptions } from '../common/util/MediaTable';
|
|
|
import FileDeletionWatcher from '../common/util/FileDeletionWatcher';
|
|
import FileDeletionWatcher from '../common/util/FileDeletionWatcher';
|
|
|
-import LyricUtil from '../common/util/LyricUtil';
|
|
|
|
|
import NetAxiosUtil from '../common/util/NetAxiosUtil';
|
|
import NetAxiosUtil from '../common/util/NetAxiosUtil';
|
|
|
import { ringtone } from '@kit.RingtoneKit';
|
|
import { ringtone } from '@kit.RingtoneKit';
|
|
|
import { BreakpointType, BreakpointTypeEnum } from '../common/util/BreakpointSystem';
|
|
import { BreakpointType, BreakpointTypeEnum } from '../common/util/BreakpointSystem';
|
|
@@ -344,6 +344,10 @@ export enum SortMode {
|
|
|
@Component
|
|
@Component
|
|
|
export struct LocalMusic {
|
|
export struct LocalMusic {
|
|
|
@State bluetoothDisconnectPause: boolean = false // 蓝牙设备断开暂停
|
|
@State bluetoothDisconnectPause: boolean = false // 蓝牙设备断开暂停
|
|
|
|
|
+ @State isBluetoothConnected: boolean = false // 蓝牙连接状态
|
|
|
|
|
+ @State bluetoothLyricEnabled: boolean = false // 蓝牙歌词开关
|
|
|
|
|
+ @State bluetoothLyricMode: number = 0 // 蓝牙歌词显示模式
|
|
|
|
|
+ private lastBluetoothLyricLine: string = '' // 上一次发送的歌词行
|
|
|
@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//开启沉浸模式
|
|
@@ -1040,10 +1044,35 @@ 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(this.bluetoothDisconnectPause&&deviceChanged.type==1&&deviceChanged.deviceDescriptors[0].deviceRole==2&&
|
|
|
|
|
- (deviceChanged.deviceDescriptors[0].deviceType==8)){
|
|
|
|
|
- console.info('heanup onecold 蓝牙音响断开, 暂停播放')
|
|
|
|
|
- this.pause();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 蓝牙设备类型为8
|
|
|
|
|
+ const isBluetooth = deviceChanged.deviceDescriptors[0].deviceType === 8;
|
|
|
|
|
+
|
|
|
|
|
+ if (isBluetooth) {
|
|
|
|
|
+ if (deviceChanged.type === 0) {
|
|
|
|
|
+ // 蓝牙连接
|
|
|
|
|
+ this.isBluetoothConnected = true;
|
|
|
|
|
+ console.info('onecold 蓝牙设备已连接');
|
|
|
|
|
+ } else if (deviceChanged.type === 1) {
|
|
|
|
|
+ // 蓝牙断开
|
|
|
|
|
+ this.isBluetoothConnected = false;
|
|
|
|
|
+ this.lastBluetoothLyricLine = '';
|
|
|
|
|
+ console.info('onecold 蓝牙设备已断开');
|
|
|
|
|
+
|
|
|
|
|
+ // 恢复原始元数据
|
|
|
|
|
+ if (this.currentSong) {
|
|
|
|
|
+ this.avSessionController.restoreOriginalMetadata(
|
|
|
|
|
+ this.currentSong.name || '',
|
|
|
|
|
+ this.currentSong.artist || ''
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 蓝牙断开暂停
|
|
|
|
|
+ if (this.bluetoothDisconnectPause && deviceChanged.deviceDescriptors[0].deviceRole === 2) {
|
|
|
|
|
+ console.info('heanup onecold 蓝牙音响断开, 暂停播放');
|
|
|
|
|
+ this.pause();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -1208,6 +1237,8 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
initSetting() {
|
|
initSetting() {
|
|
|
this.bluetoothDisconnectPause = PreferencesUtil.getBooleanSync(SettingPage.BLUETOOTH_DISCONNECT_PAUSE, false)
|
|
this.bluetoothDisconnectPause = PreferencesUtil.getBooleanSync(SettingPage.BLUETOOTH_DISCONNECT_PAUSE, false)
|
|
|
|
|
+ this.bluetoothLyricEnabled = PreferencesUtil.getBooleanSync(SettingPage.BLUETOOTH_LYRIC_ENABLED, false)
|
|
|
|
|
+ this.bluetoothLyricMode = PreferencesUtil.getNumberSync(SettingPage.BLUETOOTH_LYRIC_MODE, 0)
|
|
|
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)
|
|
@@ -14043,6 +14074,21 @@ export struct LocalMusic {
|
|
|
if(this.isShowSingleLineLyric){
|
|
if(this.isShowSingleLineLyric){
|
|
|
this.lyricControllerSingle.updatePosition(position + this.timeOffset * 1000);
|
|
this.lyricControllerSingle.updatePosition(position + this.timeOffset * 1000);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 蓝牙歌词更新逻辑
|
|
|
|
|
+ if (this.bluetoothLyricEnabled && this.isBluetoothConnected && this.lyricContent && this.currentSong) {
|
|
|
|
|
+ const currentLyricLine = LyricUtil.getCurrentLyricLine(this.lyricContent, position + this.timeOffset * 1000);
|
|
|
|
|
+ // 仅在歌词行变化时更新,避免频繁调用
|
|
|
|
|
+ if (currentLyricLine !== this.lastBluetoothLyricLine) {
|
|
|
|
|
+ this.lastBluetoothLyricLine = currentLyricLine;
|
|
|
|
|
+ this.avSessionController.updateBluetoothLyric(
|
|
|
|
|
+ currentLyricLine,
|
|
|
|
|
+ this.currentSong.name || '',
|
|
|
|
|
+ this.currentSong.artist || '',
|
|
|
|
|
+ this.bluetoothLyricMode
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
this.currentTime = this.stringForTime(position);
|
|
this.currentTime = this.stringForTime(position);
|
|
|
this.isCurrentTime = false
|
|
this.isCurrentTime = false
|