|
|
@@ -951,7 +951,7 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
* 直接播放新歌曲,避免恢复逻辑干扰
|
|
|
* 专为 playNext/playPrevious 设计
|
|
|
*/
|
|
|
- private async playNewSongDirectly(song: VideoItem | null): Promise<void> {
|
|
|
+ private async playNewSongDirectly(song: VideoItem | null, shouldAutoPlay: boolean = true): Promise<void> {
|
|
|
if (!song) {
|
|
|
throw new Error('No song provided for direct play');
|
|
|
}
|
|
|
@@ -977,6 +977,17 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
await this.playlistModel.ensureCurrentSongInHistory();
|
|
|
}
|
|
|
|
|
|
+ // 关键修复:设置播放器的自动播放状态
|
|
|
+ this.playerManager.setShouldAutoPlay(shouldAutoPlay);
|
|
|
+
|
|
|
+ // 如果需要自动播放,清除暂停状态,确保播放器能正常启动
|
|
|
+ if (shouldAutoPlay) {
|
|
|
+ this.playerManager.clearPausedState();
|
|
|
+ LogUtils.getInstance().LOGI(`UnifiedPlayerService: playNewSongDirectly - cleared paused state for auto-play`);
|
|
|
+ }
|
|
|
+
|
|
|
+ LogUtils.getInstance().LOGI(`UnifiedPlayerService: playNewSongDirectly - shouldAutoPlay: ${shouldAutoPlay}`);
|
|
|
+
|
|
|
// 设置播放源和配置
|
|
|
await this.setupPlayerForSong(song);
|
|
|
|
|
|
@@ -1129,6 +1140,11 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
// 1. 设置手动歌曲切换标志,防止自动播放等逻辑干扰
|
|
|
this.isManualSongChange = true;
|
|
|
|
|
|
+ // 关键修复:切歌操作应该总是开始播放新歌曲,无论之前是什么状态
|
|
|
+ // 这是用户的明确意图:切换到新歌曲并播放
|
|
|
+ const shouldAutoPlayNewSong = true;
|
|
|
+ LogUtils.getInstance().LOGI(`UnifiedPlayerService: changeTrack - will auto-play new song: ${shouldAutoPlayNewSong}`);
|
|
|
+
|
|
|
// 2. 检查服务是否已准备就绪
|
|
|
if (!this.isAllServicesReady()) {
|
|
|
LogUtils.getInstance().LOGI(`Heanup UnifiedPlayerService: ${direction} - 服务未就绪,等待服务初始化完成`);
|
|
|
@@ -1180,8 +1196,8 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
// 静默停止当前播放(不再保存位置,因为已经在上面保存了)
|
|
|
await this.stopSilentlyWithoutSave();
|
|
|
|
|
|
- // 直接播放新歌曲
|
|
|
- await this.playNewSongDirectly(newSong);
|
|
|
+ // 直接播放新歌曲,切歌操作总是自动播放
|
|
|
+ await this.playNewSongDirectly(newSong, shouldAutoPlayNewSong);
|
|
|
|
|
|
// 更新播放列表状态
|
|
|
await this.updatePlaylistStateInModel();
|
|
|
@@ -1239,7 +1255,7 @@ export class UnifiedPlayerService implements IPlayerService, PlaylistSyncListene
|
|
|
|
|
|
// 直接播放新歌曲,而不是恢复播放
|
|
|
const newCurrentSong = this.playlistModel.getCurrentSong();
|
|
|
- await this.playNewSongDirectly(newCurrentSong);
|
|
|
+ await this.playNewSongDirectly(newCurrentSong, true); // 直接点击播放,应该自动开始
|
|
|
|
|
|
// 更新状态模型中的播放列表状态
|
|
|
await this.updatePlaylistStateInModel();
|