|
@@ -730,7 +730,9 @@ export struct LocalMusic {
|
|
|
} else if (event.hintType === InterruptHintType.INTERRUPT_HINT_RESUME) {
|
|
} else if (event.hintType === InterruptHintType.INTERRUPT_HINT_RESUME) {
|
|
|
this.startPlayOrResumePlay();
|
|
this.startPlayOrResumePlay();
|
|
|
} else if (event.hintType === InterruptHintType.INTERRUPT_HINT_STOP) {
|
|
} else if (event.hintType === InterruptHintType.INTERRUPT_HINT_STOP) {
|
|
|
- this.stop();
|
|
|
|
|
|
|
+ // 对于STOP事件,使用pause而不是stop,保持播放状态以便恢复
|
|
|
|
|
+ LogUtils.getInstance().LOGI('onecold 音频冲突STOP事件,使用pause保持播放状态');
|
|
|
|
|
+ this.pause();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -905,6 +907,32 @@ export struct LocalMusic {
|
|
|
// 设置解码前图片数据内存缓存上限为100MB (100MB=100*1024*1024B=104857600B)
|
|
// 设置解码前图片数据内存缓存上限为100MB (100MB=100*1024*1024B=104857600B)
|
|
|
app.setImageRawDataCacheSize(104857600);
|
|
app.setImageRawDataCacheSize(104857600);
|
|
|
Logger.info('onecold onPageShow currentBreakpoint= ' + this.currentBreakpoint)
|
|
Logger.info('onecold onPageShow currentBreakpoint= ' + this.currentBreakpoint)
|
|
|
|
|
+
|
|
|
|
|
+ // 修复音频中断后的状态同步问题
|
|
|
|
|
+ this.syncPlaybackStateOnShow();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 页面显示时同步播放状态,修复音频中断后的状态不一致问题
|
|
|
|
|
+ */
|
|
|
|
|
+ private syncPlaybackStateOnShow(): void {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const currentState = this.unifiedPlayerService.getCurrentState();
|
|
|
|
|
+ const actualPlaying = this.unifiedPlayerService.getActualPlayingState();
|
|
|
|
|
+
|
|
|
|
|
+ LogUtils.getInstance().LOGI(`onPageShow state sync - StateModel: isPlaying=${currentState.isPlaying}, isPaused=${currentState.isPaused}, Actual: ${actualPlaying}`);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果状态不一致,强制同步
|
|
|
|
|
+ if (currentState.isPlaying !== actualPlaying) {
|
|
|
|
|
+ LogUtils.getInstance().LOGI(`State inconsistency detected, forcing sync`);
|
|
|
|
|
+ this.setIsPlaying(actualPlaying);
|
|
|
|
|
+ this.CONTROL_PlayStatus = actualPlaying ? PlayStatus.PLAY : PlayStatus.INIT;
|
|
|
|
|
+ this.playChange();
|
|
|
|
|
+ this.watchStatus();
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ LogUtils.getInstance().LOGI(`syncPlaybackStateOnShow error: ${error}`);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//开启线程查看各个数据库
|
|
//开启线程查看各个数据库
|
|
@@ -11345,15 +11373,16 @@ export struct LocalMusic {
|
|
|
// 使用UnifiedPlayerService停止播放
|
|
// 使用UnifiedPlayerService停止播放
|
|
|
await this.unifiedPlayerService.stop();
|
|
await this.unifiedPlayerService.stop();
|
|
|
|
|
|
|
|
- // 保持原有的UI更新逻辑
|
|
|
|
|
|
|
+ // 保持原有的UI更新逻辑 - 重要:停止时清除所有播放状态
|
|
|
this.stopProgressTask();
|
|
this.stopProgressTask();
|
|
|
- this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
|
|
|
|
|
+ this.CONTROL_PlayStatus = PlayStatus.INIT; // 初始状态,不是暂停
|
|
|
this.setIsPlaying(false);
|
|
this.setIsPlaying(false);
|
|
|
- // 注意:AVSession状态更新由UnifiedPlayerService统一处理,避免冲突
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 强制更新UI状态
|
|
|
this.playChange()
|
|
this.playChange()
|
|
|
this.watchStatus();
|
|
this.watchStatus();
|
|
|
|
|
|
|
|
- LogUtils.getInstance().LOGI("LocalMusic: stop completed via UnifiedPlayerService");
|
|
|
|
|
|
|
+ LogUtils.getInstance().LOGI("LocalMusic: stop completed - all states cleared to INIT");
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
LogUtils.getInstance().LOGI(`LocalMusic stop error: ${error}`);
|
|
LogUtils.getInstance().LOGI(`LocalMusic stop error: ${error}`);
|
|
|
ToastUtil.showToast(`停止播放失败: ${error}`);
|
|
ToastUtil.showToast(`停止播放失败: ${error}`);
|