Attach active screen share to new peers and prompt mic on join gesture
Build and Publish / Metadata (push) Successful in 2s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 25s

This commit is contained in:
mats committed 2026-09-22 10:46:28 +02:00
1 parent dee8ef4f7c
commit 45d2a4911f
1 file changed
+19 -10
+19 -10
View File
@@ -80,13 +80,12 @@ async function joinVoice(room) {
S.connecting = true;
setStatus(`connecting to ${room}…`, 'connecting');
try {
S.iceServers = await fetchIce();
} catch {
toast('Could not load ICE config from server — using fallback STUN', 'warn');
}
// Mic permission & AudioContext: request immediately on the user-click gesture
// so browsers don't block the microphone permission prompt or audio autoplay policy.
if (!S.audioCtx) S.audioCtx = new AudioContext();
await S.audioCtx.resume().catch(() => {});
orientListener();
// mic (join anyway without one — listen-only)
try {
S.micStream = await navigator.mediaDevices.getUserMedia({
audio: { echoCancellation: true, noiseSuppression: true, autoGainControl: true },
@@ -99,10 +98,11 @@ async function joinVoice(room) {
S.muted = false;
$('#btn-share').disabled = false;
// audio context must exist after a user gesture — the channel click is one
if (!S.audioCtx) S.audioCtx = new AudioContext();
await S.audioCtx.resume().catch(() => {});
orientListener();
try {
S.iceServers = await fetchIce();
} catch {
toast('Could not load ICE config from server — using fallback STUN', 'warn');
}
await openSignaling(room);
S.room = room;
@@ -398,6 +398,15 @@ function ensurePC(peer, initiator) {
pc.addTransceiver('audio', { direction: 'recvonly' });
}
// send my screen share if I am currently sharing when this peer connects
if (S.sharing && S.screenStream) {
const senders = [];
for (const track of S.screenStream.getTracks()) {
senders.push(pc.addTrack(track, S.screenStream));
}
S.screenSenders.set(peer.id, senders);
}
if (initiator) pc.onnegotiationneeded();
return peer;
}