global player pt. 9 fix play track pt. 2
This commit is contained in:
@@ -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");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user