diff --git a/zebra-report/zebra-spaces.html b/zebra-report/zebra-spaces.html index becfdce..0eb70ac 100644 --- a/zebra-report/zebra-spaces.html +++ b/zebra-report/zebra-spaces.html @@ -4085,20 +4085,32 @@ const audioPath = new Map(); // uuid -> 'dj' | 'rtc' let listenerOutputMuted = true; function applyAudioMute(){ const silenced = (myRole === 'listener' && listenerOutputMuted); + let touched = 0, played = 0, failed = 0; for (const [uuid, a] of remoteAudio){ const wantRtc = !silenced && audioPath.get(uuid) !== 'dj'; try { a.muted = !wantRtc; - if (wantRtc) { const p = a.play(); if (p && p.catch) p.catch(()=>{}); } - } catch(_){} + touched++; + if (wantRtc) { + const p = a.play(); + if (p && p.then) p.then(()=>played++).catch(e=>{ failed++; logLine('err','rtc play '+uuid+': '+e.message); }); + else played++; + } + } catch(e){ failed++; logLine('err','rtc set mute '+uuid+': '+e.message); } } for (const [uuid, a] of streamAudio){ const wantDj = !silenced && audioPath.get(uuid) === 'dj'; try { a.muted = !wantDj; - if (wantDj) { const p = a.play(); if (p && p.catch) p.catch(()=>{}); } - } catch(_){} + touched++; + if (wantDj) { + const p = a.play(); + if (p && p.then) p.then(()=>played++).catch(e=>{ failed++; logLine('err','dj play '+uuid+': '+e.message); }); + else played++; + } + } catch(e){ failed++; logLine('err','dj set mute '+uuid+': '+e.message); } } + logLine('', 'applyAudioMute silenced='+silenced+' touched='+touched+' streamMode='+streamMode.size); } function streamUrlFor(pubHex){ return SFU_BASE + '/stream?room=' + encodeURIComponent(roomID) + '&pub=' + pubHex; @@ -4189,9 +4201,11 @@ function toggleStreamFor(uuid, pubHex){ * - role-change (another peer became a speaker; or we got demoted * to listener). */ function autoEnableDjModeForListener(){ - if (myRole !== 'listener') return; + if (myRole !== 'listener') { logLine('', 'autoDJ skip: role='+myRole); return; } + let added = 0, seen = 0; for (const [uuid, mm] of members){ if (uuid === myUUID) continue; + seen++; if (!canSpeak(mm.role)) continue; if (!mm.pubkey) continue; let pubHex; @@ -4199,7 +4213,9 @@ function autoEnableDjModeForListener(){ if (streamMode.has(pubHex)) continue; streamMode.add(pubHex); startStream(uuid, pubHex); + added++; } + logLine('', 'autoDJ pass: members='+seen+' added='+added+' streamMode='+streamMode.size); } /* Periodic retry — covers the timing race where the host's mic publish * hasn't been registered at the SFU yet when the listener first @@ -4646,6 +4662,10 @@ $('btn-mute').addEventListener('click', () => { * waiting. */ if (myRole === 'listener'){ listenerOutputMuted = !listenerOutputMuted; + logLine('', 'play-button: listenerOutputMuted=' + listenerOutputMuted + + ' remoteAudio=' + remoteAudio.size + + ' streamAudio=' + streamAudio.size + + ' audioPath=' + audioPath.size); applyAudioMute(); const btn = $('btn-mute'); btn.textContent = listenerOutputMuted ? 'play' : 'mute'; @@ -4887,8 +4907,8 @@ logLine('', 'ready — pick a handle, type a rendezvous code, enter the space');