global player pt. 9 fix play track pt. 2

This commit is contained in:
2026-02-06 02:15:11 -08:00
parent 0b1a7792b4
commit 28aed104f6
2 changed files with 25 additions and 0 deletions

View File

@@ -171,6 +171,7 @@
try {
await el.play();
} catch {
// Autoplay may be blocked; bail out quietly.
return;
}
@@ -278,6 +279,23 @@
snap = s;
});
// Listen for play requests dispatched from anywhere (e.g. SongEntry buttons).
// This ensures "Play" behaves like Next/Prev: it will reliably sync the new
// source and start playback.
if (browser) {
const onAutoplayRequest = () => {
void syncAndAutoplay();
};
window.addEventListener("amqtrain:player:autoplay", onAutoplayRequest);
return () => {
window.removeEventListener(
"amqtrain:player:autoplay",
onAutoplayRequest,
);
};
}
media.setPlaybackState("paused");
});