refactor(player): 重构播放控制系统,移除 Howler.js 改用原生 HTMLAudioElement

- 新建 playbackController.ts,使用 generation-based 取消替代 playbackRequestManager 状态机
- audioService 重写:单一持久 HTMLAudioElement + Web Audio API,createMediaElementSource 只调一次
- playerCore 瘦身为纯状态管理,移除 handlePlayMusic/playAudio/checkPlaybackState
- playlist next/prev 简化,区分用户手动切歌和歌曲自然播完
- MusicHook 适配 HTMLAudioElement API(.currentTime/.duration/.paused)
- preloadService 从 Howl 实例缓存改为 URL 可用性验证
- 所有 view/component 调用者迁移到 playbackController.playTrack()

修复:快速切歌竞态、seek 到未缓冲位置失败、重启后自动播放循环提示、EQ 重建崩溃
This commit is contained in:
alger
2026-03-29 13:18:05 +08:00
parent 167f081ee6
commit 0cfec3dd82
17 changed files with 1150 additions and 1919 deletions
@@ -441,7 +441,8 @@ const handleFmPlay = async () => {
];
playlistStore.setPlayList(playlist, false, false);
playerCore.isFmPlaying = true;
await playerCore.handlePlayMusic(playlist[0], true);
const { playTrack } = await import('@/services/playbackController');
await playTrack(playlist[0], true);
} catch (error) {
console.error('Failed to play Personal FM:', error);
}
@@ -597,9 +598,7 @@ const showDayRecommend = () => {
const playDayRecommend = async () => {
if (dayRecommendSongs.value.length === 0) return;
try {
const { usePlayerCoreStore } = await import('@/store/modules/playerCore');
const { usePlaylistStore } = await import('@/store/modules/playlist');
const playerCore = usePlayerCoreStore();
const playlistStore = usePlaylistStore();
const songs = dayRecommendSongs.value.map((s: any) => ({
id: s.id,
@@ -611,7 +610,8 @@ const playDayRecommend = async () => {
playLoading: false
}));
playlistStore.setPlayList(songs, false, false);
await playerCore.handlePlayMusic(songs[0], true);
const { playTrack } = await import('@/services/playbackController');
await playTrack(songs[0], true);
} catch (error) {
console.error('Failed to play daily recommend:', error);
}