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
3590a59c10
commit
9547e31829
|
|
@ -355,6 +355,17 @@
|
|||
(setf *is-reconnecting* t)
|
||||
(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)
|
||||
(ps:chain audio-element
|
||||
(add-event-listener "waiting"
|
||||
|
|
|
|||
|
|
@ -300,6 +300,19 @@
|
|||
reconnectStream();
|
||||
}, 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
|
||||
|
|
|
|||
|
|
@ -178,6 +178,18 @@
|
|||
}, 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
|
||||
if (window.opener && !window.opener.closed) {
|
||||
window.opener.postMessage({ type: 'popout-opened' }, '*');
|
||||
|
|
|
|||
Loading…
Reference in New Issue