exp(orbit): polish pass

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Psychotoxical
2026-04-23 17:23:28 +02:00
parent 11dddf6290
commit c7af6a6e15
3 changed files with 119 additions and 20 deletions
+8 -7
View File
@@ -108,24 +108,25 @@ export default function OrbitSessionBar() {
const trackId = state.currentTrack.trackId;
const targetMs = estimateLivePosition(state, Date.now());
const targetSec = Math.max(0, targetMs / 1000);
const hostPlaying = state.isPlaying;
try {
const song = await getSong(trackId);
if (!song) return;
const track = songToTrack(song);
const player = usePlayerStore.getState();
const fraction = targetSec / Math.max(1, track.duration);
if (player.currentTrack?.id === trackId) {
// Same track: just seek + resume.
player.seek(targetSec / Math.max(1, track.duration));
if (!player.isPlaying) player.resume();
player.seek(fraction);
if (hostPlaying && !player.isPlaying) player.resume();
else if (!hostPlaying && player.isPlaying) player.pause();
} else {
// Different track: play + seek on next tick once engine is ready.
player.playTrack(track, [track]);
// Best-effort: seek to the host's position a beat later.
window.setTimeout(() => {
const p = usePlayerStore.getState();
if (p.currentTrack?.id === trackId) {
p.seek(targetSec / Math.max(1, track.duration));
}
if (p.currentTrack?.id !== trackId) return;
p.seek(fraction);
if (!hostPlaying && p.isPlaying) p.pause();
}, 400);
}
} catch {