Skip to content

Commit ae51e70

Browse files
author
Datanoise
committed
fix: resolve aggressive player reconnection loop using guard flag
1 parent 88a30f7 commit ae51e70

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

server/templates/player.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
let audioCtx, analyser, source, animationId, pc;
129129
let smoothedAvg = 0;
130130
let reconnectAttempts = 0;
131+
let isReconnecting = false;
131132

132133
if (useWebRTC) {
133134
modePill.classList.add('webrtc');
@@ -257,15 +258,21 @@
257258
};
258259

259260
function reconnect() {
260-
if (isPlaying && !useWebRTC) {
261+
if (isPlaying && !useWebRTC && !isReconnecting) {
262+
isReconnecting = true;
261263
// Reconnect rate: ~1 second + tiny bit of random (0-200ms)
262264
const delay = 1000 + (Math.random() * 200);
263265
setTimeout(() => {
264-
if (!isPlaying) return;
266+
if (!isPlaying) {
267+
isReconnecting = false;
268+
return;
269+
}
265270
audio.src = mount + '?t=' + new Date().getTime();
266271
audio.play().then(() => {
267272
reconnectAttempts = 0;
273+
isReconnecting = false;
268274
}).catch(() => {
275+
isReconnecting = false;
269276
reconnect();
270277
});
271278
}, delay);

tinyice.pid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
38392
1+
38637

0 commit comments

Comments
 (0)