Compare commits
3
Commits
d87abd2e9e
...
751cc05b89
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
751cc05b89 | ||
|
|
10e3e0eb1d | ||
|
|
a1a4416bb6 |
+29
-7
@@ -98,9 +98,17 @@ window.NSPlayer = {
|
||||
onPlaybackStateChanged(stateJson) {
|
||||
try {
|
||||
const state = JSON.parse(stateJson);
|
||||
if (state.isPlaying) { _skipping = false; clearTimeout(_skipTimer); }
|
||||
// Suppress the transient isPlaying:false emitted by the native player during track transitions.
|
||||
if (!state.isPlaying && _skipping) return;
|
||||
if (_skipping) {
|
||||
if (state.isPlaying) {
|
||||
// isPlaying:true during skip/seek — restart grace period instead of clearing immediately,
|
||||
// so a follow-up buffering false event is also suppressed.
|
||||
clearTimeout(_skipTimer);
|
||||
_skipTimer = setTimeout(() => { _skipping = false; }, 600);
|
||||
} else {
|
||||
// Suppress transient isPlaying:false during track transitions / seeks.
|
||||
return;
|
||||
}
|
||||
}
|
||||
const prev = _nativePlaying;
|
||||
_nativePlaying = state.isPlaying;
|
||||
if (state.isPlaying !== prev) {
|
||||
@@ -275,6 +283,7 @@ export function playCurrent() {
|
||||
if (HAS_BRIDGE) {
|
||||
// Update DOM immediately for snappy feedback; onTrackChanged will confirm.
|
||||
S._trackChanging = true;
|
||||
_resetProgressUI();
|
||||
updatePlayerUI(s, true);
|
||||
onNpSongChange(s.id);
|
||||
renderQueue();
|
||||
@@ -285,6 +294,7 @@ export function playCurrent() {
|
||||
|
||||
const gen = ++_playGen;
|
||||
S._trackChanging = true;
|
||||
_resetProgressUI();
|
||||
if(navigator.mediaSession) navigator.mediaSession.playbackState = 'playing';
|
||||
updatePlayerUI(s, true);
|
||||
onNpSongChange(s.id);
|
||||
@@ -463,20 +473,32 @@ function _setSkipping() {
|
||||
_skipTimer = setTimeout(() => { _skipping = false; }, 2000);
|
||||
}
|
||||
|
||||
function _resetProgressUI() {
|
||||
if (HAS_BRIDGE) _nativePos = 0;
|
||||
document.getElementById('progress-fill').style.width = '0%';
|
||||
document.getElementById('time-cur').textContent = formatDur(0);
|
||||
if (S.npOpen) {
|
||||
const fill = document.getElementById('np-fill');
|
||||
const cur = document.getElementById('np-cur');
|
||||
if (fill) fill.style.width = '0%';
|
||||
if (cur) cur.textContent = formatDur(0);
|
||||
}
|
||||
}
|
||||
|
||||
export function prevSong() {
|
||||
_clearPreload();
|
||||
if (HAS_BRIDGE) {
|
||||
_setSkipping();
|
||||
if (_lastPositionMs > 3000) { _nsBridge('prev'); return; }
|
||||
if (_lastPositionMs > 3000) { _resetProgressUI(); _nsBridge('prev'); return; }
|
||||
if (S.qIdx > 0) {
|
||||
S.qIdx--;
|
||||
const s = S.queue[S.qIdx];
|
||||
if (s) { updatePlayerUI(s, true); onNpSongChange(s.id); renderQueue(); }
|
||||
if (s) { _resetProgressUI(); updatePlayerUI(s, true); onNpSongChange(s.id); renderQueue(); }
|
||||
}
|
||||
_nsBridge('prev');
|
||||
return;
|
||||
}
|
||||
if(S.audio.currentTime > 3) { S.audio.currentTime = 0; return; }
|
||||
if(S.audio.currentTime > 3) { _resetProgressUI(); S.audio.currentTime = 0; return; }
|
||||
if(S.qIdx > 0) { S.qIdx--; playCurrent(); }
|
||||
}
|
||||
|
||||
@@ -488,7 +510,7 @@ export function nextSong() {
|
||||
if (ni >= 0 && ni < S.queue.length) {
|
||||
S.qIdx = ni;
|
||||
const s = S.queue[S.qIdx];
|
||||
if (s) { updatePlayerUI(s, true); onNpSongChange(s.id); renderQueue(); }
|
||||
if (s) { _resetProgressUI(); updatePlayerUI(s, true); onNpSongChange(s.id); renderQueue(); }
|
||||
}
|
||||
_nsBridge('next');
|
||||
if (S.radioMode && S.queue.length - S.qIdx < 5) fillRadioQueue();
|
||||
|
||||
Reference in new issue
Block a user