Refactor code structure for improved readability and maintainability

This commit is contained in:
2025-10-19 22:08:17 +02:00
parent bec0a3b72f
commit 445f522fa8
11 changed files with 2242 additions and 2182 deletions

View File

@@ -79,6 +79,13 @@ export function handlePlayTrack(msg) {
try {
$audio.preload = 'auto';
} catch {}
// Reset audio state before setting new source
try {
$audio.pause();
$audio.currentTime = 0;
} catch {}
$audio.src = t.url;
const pf = document.getElementById('progressFill');
if (pf) pf.style.width = '0%';
@@ -93,7 +100,7 @@ export function handlePlayTrack(msg) {
const localStart = now + offsetMs;
const delay = Math.max(0, localStart - now);
setTimeout(() => {
$audio.currentTime = 0;
// Don't reset currentTime again - it's already 0 from above
$audio.play().catch(() => {});
const disc = document.getElementById('recordDisc');
if (disc) disc.classList.add('spin-record');