voice-poc: wire up screen share button (S shortcut, active/disabled states)

This commit is contained in:
mats committed 2026-09-22 07:12:58 +00:00
1 parent 404dae3a28
commit ebbf1b07d8
4 files changed
+9 -1

No files matched your search

+6
View File
@@ -93,6 +93,7 @@ async function joinVoice(room) {
}
els.mic.disabled = !S.micStream;
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();
@@ -117,6 +118,7 @@ function leaveVoice(reason) {
if (S.ws) { try { S.ws.close(); } catch {} S.ws = null; }
if (S.micStream) { S.micStream.getTracks().forEach((t) => t.stop()); S.micStream = null; }
els.mic.disabled = false;
$('#btn-share').disabled = true;
updateMicButton();
document.querySelectorAll('.channel.voice').forEach((c) => c.classList.remove('active'));
S.room = null;
@@ -402,6 +404,7 @@ async function startScreenShare() {
stream.getVideoTracks()[0].addEventListener('ended', () => stopScreenShare());
renderScreens();
renderTiles();
$('#btn-share').classList.add('active');
toast('You are sharing your screen', 'ok');
}
@@ -426,6 +429,7 @@ function stopScreenShare(silent) {
send({ type: 'state', state: { muted: S.muted, deafened: S.deafened, sharing: false } });
renderScreens();
renderTiles();
$('#btn-share').classList.remove('active');
if (!silent) toast('Screen share stopped');
}
@@ -703,6 +707,7 @@ function toggleDeafen() {
els.mic.onclick = toggleMic;
els.deafen.onclick = toggleDeafen;
$('#btn-share').onclick = () => (S.sharing ? stopScreenShare() : startScreenShare());
$('#btn-settings').onclick = openSettings;
els.nick.value = S.name;
@@ -748,6 +753,7 @@ window.addEventListener('keydown', (ev) => {
if (ev.target.tagName === 'INPUT' || ev.target.tagName === 'TEXTAREA') return;
if (ev.key === 'm') toggleMic();
if (ev.key === 'd') toggleDeafen();
if (ev.key === 's' && S.room) $('#btn-share').click();
});
window.addEventListener('beforeunload', () => { try { leaveVoice(); } catch {} });