Skip to content

Commit 07072e9

Browse files
committed
update collab participant to auto enable mic and webcam, update rendering for mobile users
1 parent d5d508b commit 07072e9

2 files changed

Lines changed: 89 additions & 3 deletions

File tree

server/app/static/collaboration/room.css

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,73 @@ body {
177177
flex-shrink: 0;
178178
}
179179

180+
@media (max-width: 768px), (max-height: 500px) {
181+
#video-grid {
182+
height: 20vh;
183+
min-height: 80px;
184+
max-height: 160px;
185+
padding: 5px;
186+
align-items: stretch;
187+
}
188+
189+
#video-grid-content {
190+
height: 100%;
191+
align-items: center;
192+
}
193+
194+
.video-container {
195+
height: 100%;
196+
width: auto;
197+
min-width: 0;
198+
aspect-ratio: 4/3;
199+
font-size: 0.75rem;
200+
}
201+
202+
#start-menu-btn {
203+
width: auto;
204+
min-width: 0;
205+
aspect-ratio: 1/1;
206+
}
207+
208+
.start-btn-inner i {
209+
font-size: 1.5em;
210+
}
211+
212+
.start-btn-inner span {
213+
display: none;
214+
}
215+
216+
#gamepad-source-box {
217+
aspect-ratio: 1/1;
218+
width: auto;
219+
min-width: 0;
220+
gap: 2px;
221+
padding: 2px;
222+
}
223+
224+
.gamepad-icon {
225+
font-size: 0.8rem;
226+
border-width: 1px;
227+
}
228+
229+
.gamepad-icon .gamepad-number {
230+
font-size: 0.6em;
231+
bottom: 1px;
232+
right: 2px;
233+
}
234+
235+
.video-overlay {
236+
padding: 2px;
237+
font-size: 0.7em;
238+
}
239+
240+
.remote-control-btn {
241+
width: 20px;
242+
height: 20px;
243+
font-size: 0.7em;
244+
}
245+
}
246+
180247
.video-container.reorderable {
181248
cursor: grab;
182249
}

server/app/static/collaboration/room.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ if (typeof MediaStreamTrackProcessor === 'undefined') {
4646
this.readable = new ReadableStream({
4747
async start(controller) {
4848
const ctx = new AudioContext();
49-
// Worklet to pass raw audio data to main thread
5049
const workletCode = `registerProcessor("mstp-shim",class extends AudioWorkletProcessor{process(i){if(i[0].length>0)this.port.postMessage(i[0]);return true}})`
5150
await ctx.audioWorklet.addModule(`data:text/javascript,${workletCode}`).catch(e => console.error(e));
5251

@@ -57,7 +56,6 @@ if (typeof MediaStreamTrackProcessor === 'undefined') {
5756
node.port.onmessage = ({data: channels}) => {
5857
if (!channels || channels.length === 0) return;
5958

60-
// Flatten planar data (array of Float32Arrays) to interleaved Float32Array
6159
const length = channels[0].length;
6260
const numChannels = channels.length;
6361
const flattened = new Float32Array(length * numChannels);
@@ -1427,7 +1425,7 @@ document.addEventListener('DOMContentLoaded', () => {
14271425
}
14281426
};
14291427

1430-
const handleUsernameSubmit = (e) => {
1428+
const handleUsernameSubmit = async (e) => {
14311429
e.preventDefault();
14321430
const input = document.getElementById('username-input');
14331431
const newUsername = input.value.trim();
@@ -1438,6 +1436,27 @@ document.addEventListener('DOMContentLoaded', () => {
14381436
sessionStorage.setItem('collab_hasJoined_' + COLLAB_DATA.sessionId, 'true');
14391437
ws.send(JSON.stringify({ action: 'set_username', username: username }));
14401438
renderSidebar();
1439+
1440+
if (!mediaInitialized) {
1441+
await startMedia();
1442+
}
1443+
1444+
isMicOn = true;
1445+
if (localStream) localStream.getAudioTracks().forEach(t => t.enabled = true);
1446+
sendControlMessage('audio_state', true);
1447+
updateMediaButtonUI();
1448+
1449+
await new Promise(r => setTimeout(r, 1000));
1450+
1451+
isWebcamOn = true;
1452+
if (localStream && localStream.getVideoTracks().length > 0) {
1453+
localStream.getVideoTracks().forEach(t => t.enabled = true);
1454+
localContainer.style.display = 'flex';
1455+
sendControlMessage('video_state', true);
1456+
}
1457+
updateMediaButtonUI();
1458+
1459+
toggleSidebar();
14411460
}
14421461
};
14431462

0 commit comments

Comments
 (0)