diff --git a/src/nowplaying.js b/src/nowplaying.js index d7dd8fa..67b0c15 100644 --- a/src/nowplaying.js +++ b/src/nowplaying.js @@ -2,7 +2,7 @@ import { S } from './state.js'; import { esc } from './utils.js'; import { coverUrl } from './api.js'; // Circular imports — safe (only used inside function bodies) -import { playCurrent, _syncNpDirect, dlSongLocal, npToggleStar, _syncOverlayState } from './player.js'; +import { playCurrent, _syncNpDirect, dlSongLocal, npToggleStar, _syncOverlayState, isPlaying } from './player.js'; import { navigate } from './views.js'; import { openPlModal, showSongInfo } from './ui.js'; @@ -57,7 +57,7 @@ export function syncNowPlaying() { if(shuffleBtn) shuffleBtn.classList.toggle('active', S.shuffle); if(repeatBtn) repeatBtn.classList.toggle('active', S.repeat !== false); if(volSlider) volSlider.value = Math.round(Math.sqrt(S.audio.volume) * 100); - const playing = !S.audio.paused; + const playing = isPlaying(); const npIcon = document.getElementById('np-play-icon'); if(npIcon) npIcon.innerHTML = playing ? '' diff --git a/src/player.js b/src/player.js index f9a4227..088ac49 100644 --- a/src/player.js +++ b/src/player.js @@ -425,6 +425,8 @@ export function togglePlay() { if(S.audio.src) S.audio.paused ? S.audio.play() : S.audio.pause(); } +export const isPlaying = () => HAS_BRIDGE ? _nativePlaying : !S.audio.paused; + export function setPlayIcon(playing) { document.getElementById('play-icon').innerHTML = playing ? ''