fix: use isPlaying() in syncNowPlaying to handle bridge/native mode
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c5fe53f13
commit
1e61d35018
2 files changed
+4
-2
No files matched your search
+2
-2
@@ -2,7 +2,7 @@ import { S } from './state.js';
|
|||||||
import { esc } from './utils.js';
|
import { esc } from './utils.js';
|
||||||
import { coverUrl } from './api.js';
|
import { coverUrl } from './api.js';
|
||||||
// Circular imports — safe (only used inside function bodies)
|
// 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 { navigate } from './views.js';
|
||||||
import { openPlModal, showSongInfo } from './ui.js';
|
import { openPlModal, showSongInfo } from './ui.js';
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ export function syncNowPlaying() {
|
|||||||
if(shuffleBtn) shuffleBtn.classList.toggle('active', S.shuffle);
|
if(shuffleBtn) shuffleBtn.classList.toggle('active', S.shuffle);
|
||||||
if(repeatBtn) repeatBtn.classList.toggle('active', S.repeat !== false);
|
if(repeatBtn) repeatBtn.classList.toggle('active', S.repeat !== false);
|
||||||
if(volSlider) volSlider.value = Math.round(Math.sqrt(S.audio.volume) * 100);
|
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');
|
const npIcon = document.getElementById('np-play-icon');
|
||||||
if(npIcon) npIcon.innerHTML = playing
|
if(npIcon) npIcon.innerHTML = playing
|
||||||
? '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>'
|
? '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>'
|
||||||
|
|||||||
@@ -425,6 +425,8 @@ export function togglePlay() {
|
|||||||
if(S.audio.src) S.audio.paused ? S.audio.play() : S.audio.pause();
|
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) {
|
export function setPlayIcon(playing) {
|
||||||
document.getElementById('play-icon').innerHTML = playing
|
document.getElementById('play-icon').innerHTML = playing
|
||||||
? '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>'
|
? '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>'
|
||||||
|
|||||||
Reference in new issue
Block a user