fix: restart skip grace period on isPlaying:true to suppress multi-fire buffering during seek
This commit is contained in:
1 parent
d87abd2e9e
commit
a1a4416bb6
1 file changed
+11
-3
+11
-3
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user