Add pause event handler for muted stream throttling
- Detect when browser pauses muted stream (throttling) - Auto-reconnect after 3 seconds when paused while muted - Apply to all three players for consistency
This commit is contained in:
parent
2cd128260c
commit
b29e504bb3
|
|
@ -355,6 +355,17 @@
|
||||||
(setf *is-reconnecting* t)
|
(setf *is-reconnecting* t)
|
||||||
(set-timeout reconnect-stream 2000))))
|
(set-timeout reconnect-stream 2000))))
|
||||||
|
|
||||||
|
;; Pause handler - detect browser throttling muted streams
|
||||||
|
(ps:chain audio-element
|
||||||
|
(add-event-listener "pause"
|
||||||
|
(lambda ()
|
||||||
|
(when (and (ps:@ audio-element muted)
|
||||||
|
(not *is-reconnecting*))
|
||||||
|
(ps:chain console (log "Stream paused while muted (possible browser throttling), reconnecting..."))
|
||||||
|
(show-stream-status "⚠️ Stream paused - reconnecting..." "warning")
|
||||||
|
(setf *is-reconnecting* t)
|
||||||
|
(set-timeout reconnect-stream 3000)))))
|
||||||
|
|
||||||
;; Waiting handler (buffering)
|
;; Waiting handler (buffering)
|
||||||
(ps:chain audio-element
|
(ps:chain audio-element
|
||||||
(add-event-listener "waiting"
|
(add-event-listener "waiting"
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,19 @@
|
||||||
reconnectStream();
|
reconnectStream();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle pause event - detect browser throttling muted streams
|
||||||
|
audioElement.addEventListener('pause', function() {
|
||||||
|
// If paused while muted and we didn't initiate it, browser may have throttled
|
||||||
|
if (audioElement.muted && !isReconnecting) {
|
||||||
|
console.log('Stream paused while muted (possible browser throttling), will reconnect in 3 seconds...');
|
||||||
|
showStatus('⚠️ Stream paused - reconnecting...', true);
|
||||||
|
isReconnecting = true;
|
||||||
|
setTimeout(function() {
|
||||||
|
reconnectStream();
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach listeners to initial audio element
|
// Attach listeners to initial audio element
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,18 @@
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle pause event - detect browser throttling muted streams
|
||||||
|
audioElement.addEventListener('pause', function() {
|
||||||
|
if (audioElement.muted && !isReconnecting) {
|
||||||
|
console.log('Stream paused while muted (possible browser throttling), reconnecting...');
|
||||||
|
isReconnecting = true;
|
||||||
|
setTimeout(function() {
|
||||||
|
audioElement.load();
|
||||||
|
audioElement.play().catch(err => console.log('Reconnect failed:', err));
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Notify parent window that popout is open
|
// Notify parent window that popout is open
|
||||||
if (window.opener && !window.opener.closed) {
|
if (window.opener && !window.opener.closed) {
|
||||||
window.opener.postMessage({ type: 'popout-opened' }, '*');
|
window.opener.postMessage({ type: 'popout-opened' }, '*');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue