Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user