|
@@ -2655,6 +2655,8 @@ export struct LocalMusic {
|
|
|
} else {
|
|
} else {
|
|
|
ToastUtil.showToast('取消收藏成功');
|
|
ToastUtil.showToast('取消收藏成功');
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 先更新收藏列表和其他UI
|
|
|
this.deleteCache(this.currentPath)
|
|
this.deleteCache(this.currentPath)
|
|
|
this.getFavList(false)
|
|
this.getFavList(false)
|
|
|
if (this.modeType === 0 && !this.isFavMusic) {
|
|
if (this.modeType === 0 && !this.isFavMusic) {
|
|
@@ -2664,6 +2666,9 @@ export struct LocalMusic {
|
|
|
workerInstance.postMessage({ code: 2, data: this.context });
|
|
workerInstance.postMessage({ code: 2, data: this.context });
|
|
|
workerInstance.postMessage({ code: 3, data: this.context });
|
|
workerInstance.postMessage({ code: 3, data: this.context });
|
|
|
workerInstance.postMessage({ code: 4, data: this.context });
|
|
workerInstance.postMessage({ code: 4, data: this.context });
|
|
|
|
|
+
|
|
|
|
|
+ // 刷新UnifiedPlayerService的收藏状态,这会自动更新AVSession
|
|
|
|
|
+ await this.unifiedPlayerService.refreshFavoriteStatus();
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -9990,7 +9995,7 @@ export struct LocalMusic {
|
|
|
// 更新播放状态
|
|
// 更新播放状态
|
|
|
this.CONTROL_PlayStatus = PlayStatus.PLAY;
|
|
this.CONTROL_PlayStatus = PlayStatus.PLAY;
|
|
|
this.setIsPlaying(true);
|
|
this.setIsPlaying(true);
|
|
|
- this.updateSessionPlayState(true);
|
|
|
|
|
|
|
+ // 注意:AVSession状态更新由UnifiedPlayerService统一处理,避免冲突
|
|
|
|
|
|
|
|
LogUtils.getInstance().LOGI("LocalMusic: startPlayOrResumePlay completed via UnifiedPlayerService");
|
|
LogUtils.getInstance().LOGI("LocalMusic: startPlayOrResumePlay completed via UnifiedPlayerService");
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -10006,7 +10011,7 @@ export struct LocalMusic {
|
|
|
private handlePlaybackError() {
|
|
private handlePlaybackError() {
|
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
|
this.setIsPlaying(false);
|
|
this.setIsPlaying(false);
|
|
|
- this.updateSessionPlayState(false);
|
|
|
|
|
|
|
+ // 注意:AVSession状态更新由UnifiedPlayerService统一处理,避免冲突
|
|
|
this.mDestroyPage = true;
|
|
this.mDestroyPage = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -10303,13 +10308,11 @@ export struct LocalMusic {
|
|
|
if (this.isCurrentTime) {
|
|
if (this.isCurrentTime) {
|
|
|
// 如果歌曲刚刚切换,强制重置并使用新时间
|
|
// 如果歌曲刚刚切换,强制重置并使用新时间
|
|
|
if (this.justSwitched) {
|
|
if (this.justSwitched) {
|
|
|
- console.log(`Heanup stringForTime歌曲刚切换 - 强制重置oldSeconds: ${this.oldSeconds} -> ${seconds}, 强制使用新时间`);
|
|
|
|
|
this.oldSeconds = seconds; // 直接使用新时间
|
|
this.oldSeconds = seconds; // 直接使用新时间
|
|
|
this.justSwitched = false; // 重置标志
|
|
this.justSwitched = false; // 重置标志
|
|
|
this.lastSwitchTime = Date.now(); // 记录切换时间
|
|
this.lastSwitchTime = Date.now(); // 记录切换时间
|
|
|
} else if (this.isSeekTo) {
|
|
} else if (this.isSeekTo) {
|
|
|
// 如果是拖动进度条,直接使用新时间
|
|
// 如果是拖动进度条,直接使用新时间
|
|
|
- console.log(`Heanup stringForTime拖动进度条 - 直接使用新时间: ${seconds}`);
|
|
|
|
|
this.oldSeconds = seconds;
|
|
this.oldSeconds = seconds;
|
|
|
} else {
|
|
} else {
|
|
|
// 正常播放时的防抖逻辑
|
|
// 正常播放时的防抖逻辑
|
|
@@ -10323,20 +10326,16 @@ export struct LocalMusic {
|
|
|
if (timeDiff > 10) {
|
|
if (timeDiff > 10) {
|
|
|
// 如果在冷却期内,允许更大的时间跳跃(可能是新歌曲开始播放)
|
|
// 如果在冷却期内,允许更大的时间跳跃(可能是新歌曲开始播放)
|
|
|
if (isInCooldown) {
|
|
if (isInCooldown) {
|
|
|
- console.log(`Heanup stringForTime切换后冷却期内检测到时间跳跃 - oldSeconds: ${this.oldSeconds}, newSeconds: ${seconds}, diff: ${timeDiff}, 允许跳跃`);
|
|
|
|
|
this.oldSeconds = seconds;
|
|
this.oldSeconds = seconds;
|
|
|
} else {
|
|
} else {
|
|
|
// 不在冷却期内,可能是异常情况,记录但使用新时间
|
|
// 不在冷却期内,可能是异常情况,记录但使用新时间
|
|
|
- console.log(`Heanup stringForTime检测到异常时间跳跃 - oldSeconds: ${this.oldSeconds}, newSeconds: ${seconds}, diff: ${timeDiff},直接使用新时间`);
|
|
|
|
|
this.oldSeconds = seconds;
|
|
this.oldSeconds = seconds;
|
|
|
}
|
|
}
|
|
|
} else if (this.oldSeconds <= seconds || seconds === 0) {
|
|
} else if (this.oldSeconds <= seconds || seconds === 0) {
|
|
|
// 正常时间递进或重置为0
|
|
// 正常时间递进或重置为0
|
|
|
- console.log(`Heanup stringForTime正常更新 - oldSeconds: ${this.oldSeconds} -> ${seconds}`);
|
|
|
|
|
this.oldSeconds = seconds;
|
|
this.oldSeconds = seconds;
|
|
|
} else {
|
|
} else {
|
|
|
// 时间倒退,使用防抖
|
|
// 时间倒退,使用防抖
|
|
|
- console.log(`Heanup stringForTime防抖 - oldSeconds: ${this.oldSeconds}, newSeconds: ${seconds}, 使用oldSeconds`);
|
|
|
|
|
seconds = this.oldSeconds;
|
|
seconds = this.oldSeconds;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -10632,21 +10631,10 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
private sessionToggleFavoriteCallback = (assetId: string) => {
|
|
private sessionToggleFavoriteCallback = (assetId: string) => {
|
|
|
if (this.currentSong) {
|
|
if (this.currentSong) {
|
|
|
- console.info(`on toggleFavorite `);
|
|
|
|
|
|
|
+ console.info(`on toggleFavorite - 播控中心收藏按钮被点击`);
|
|
|
// 应用收到收藏命令,进行收藏处理。
|
|
// 应用收到收藏命令,进行收藏处理。
|
|
|
-
|
|
|
|
|
- this.isFac = Utility.getIsFav(this.favList, this.currentSong)
|
|
|
|
|
- this.doFav(this.currentSong)
|
|
|
|
|
- // 应用内完成或者取消收藏,把新的收藏状态设置给AVSession。
|
|
|
|
|
- let playbackState: avSession.AVPlaybackState = {
|
|
|
|
|
- isFavorite: !this.isFac,
|
|
|
|
|
- };
|
|
|
|
|
- // this.avSessionController.setAvSessionPlayState(playbackState);
|
|
|
|
|
- // this.avSessionController.getAvSession()?.setAVPlaybackState(playbackState).then(() => {
|
|
|
|
|
- // console.info(`SetAVPlaybackState successfully`+assetId+this.isFac);
|
|
|
|
|
- // }).catch((err: BusinessError) => {
|
|
|
|
|
- // console.info(`SetAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ // 注意:这里不需要立即更新AVSession状态,因为doFav方法内部会处理状态更新
|
|
|
|
|
+ this.doFav(this.currentSong);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
private sessionOutputDeviceChange = async (connectState: avSession.ConnectionState,
|
|
private sessionOutputDeviceChange = async (connectState: avSession.ConnectionState,
|
|
@@ -11359,7 +11347,7 @@ export struct LocalMusic {
|
|
|
this.setProgress();
|
|
this.setProgress();
|
|
|
this.mDestroyPage = true;
|
|
this.mDestroyPage = true;
|
|
|
this.CONTROL_PlayStatus = PlayStatus.PAUSE;
|
|
this.CONTROL_PlayStatus = PlayStatus.PAUSE;
|
|
|
- this.updateSessionPlayState(false)
|
|
|
|
|
|
|
+ // 注意:AVSession状态更新由UnifiedPlayerService统一处理,避免冲突
|
|
|
this.playChange()
|
|
this.playChange()
|
|
|
if (this.pipController) {
|
|
if (this.pipController) {
|
|
|
this.pipController.updatePiPControlStatus(PiPWindow.PiPControlType.VIDEO_PLAY_PAUSE,
|
|
this.pipController.updatePiPControlStatus(PiPWindow.PiPControlType.VIDEO_PLAY_PAUSE,
|
|
@@ -11400,7 +11388,7 @@ export struct LocalMusic {
|
|
|
this.stopProgressTask();
|
|
this.stopProgressTask();
|
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
this.CONTROL_PlayStatus = PlayStatus.INIT;
|
|
|
this.setIsPlaying(false);
|
|
this.setIsPlaying(false);
|
|
|
- this.updateSessionPlayState(false)
|
|
|
|
|
|
|
+ // 注意:AVSession状态更新由UnifiedPlayerService统一处理,避免冲突
|
|
|
this.playChange()
|
|
this.playChange()
|
|
|
this.watchStatus();
|
|
this.watchStatus();
|
|
|
|
|
|