Samir621 commited on
Commit
581f60b
·
verified ·
1 Parent(s): d740034

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +635 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Connecthub
3
- emoji: 🏆
4
- colorFrom: green
5
- colorTo: red
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: connecthub
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: yellow
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,635 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>ConnectHub - Video Calling Platform</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .video-container {
11
+ position: relative;
12
+ width: 100%;
13
+ height: 100%;
14
+ border-radius: 8px;
15
+ overflow: hidden;
16
+ background-color: #1e293b;
17
+ }
18
+
19
+ .video-grid {
20
+ display: grid;
21
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
22
+ gap: 16px;
23
+ padding: 16px;
24
+ height: calc(100vh - 120px);
25
+ }
26
+
27
+ .video-item {
28
+ position: relative;
29
+ border-radius: 8px;
30
+ overflow: hidden;
31
+ transition: all 0.3s ease;
32
+ }
33
+
34
+ .video-info {
35
+ position: absolute;
36
+ bottom: 0;
37
+ left: 0;
38
+ right: 0;
39
+ background: rgba(0, 0, 0, 0.5);
40
+ color: white;
41
+ padding: 8px;
42
+ font-size: 14px;
43
+ }
44
+
45
+ .controls {
46
+ position: fixed;
47
+ bottom: 0;
48
+ left: 0;
49
+ right: 0;
50
+ background: white;
51
+ padding: 12px;
52
+ display: flex;
53
+ justify-content: center;
54
+ gap: 16px;
55
+ box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
56
+ }
57
+
58
+ .control-btn {
59
+ width: 50px;
60
+ height: 50px;
61
+ border-radius: 50%;
62
+ display: flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+ cursor: pointer;
66
+ transition: all 0.2s ease;
67
+ }
68
+
69
+ .end-call {
70
+ background-color: #ef4444;
71
+ color: white;
72
+ }
73
+
74
+ .muted {
75
+ background-color: #ef4444;
76
+ color: white;
77
+ }
78
+
79
+ .video-off {
80
+ background-color: #ef4444;
81
+ color: white;
82
+ }
83
+
84
+ .modal {
85
+ display: none;
86
+ position: fixed;
87
+ top: 0;
88
+ left: 0;
89
+ width: 100%;
90
+ height: 100%;
91
+ background-color: rgba(0, 0, 0, 0.7);
92
+ z-index: 1000;
93
+ align-items: center;
94
+ justify-content: center;
95
+ }
96
+
97
+ .modal-content {
98
+ background-color: white;
99
+ padding: 24px;
100
+ border-radius: 8px;
101
+ width: 90%;
102
+ max-width: 500px;
103
+ }
104
+
105
+ #local-video {
106
+ transform: scaleX(-1); /* Mirror effect for self-view */
107
+ }
108
+ </style>
109
+ </head>
110
+ <body class="bg-gray-100">
111
+ <!-- Pre-call screen -->
112
+ <div id="pre-call" class="flex flex-col items-center justify-center h-screen">
113
+ <div class="bg-white p-8 rounded-lg shadow-lg w-full max-w-md">
114
+ <h1 class="text-3xl font-bold text-center text-blue-600 mb-6">ConnectHub</h1>
115
+ <div class="mb-6">
116
+ <label for="room-id" class="block text-sm font-medium text-gray-700 mb-1">Meeting ID</label>
117
+ <input type="text" id="room-id" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter or create meeting ID">
118
+ </div>
119
+ <div class="mb-6">
120
+ <label for="user-name" class="block text-sm font-medium text-gray-700 mb-1">Your Name</label>
121
+ <input type="text" id="user-name" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter your name">
122
+ </div>
123
+ <div class="flex space-x-4">
124
+ <button id="new-meeting" class="flex-1 bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
125
+ <i class="fas fa-video mr-2"></i> New Meeting
126
+ </button>
127
+ <button id="join-meeting" class="flex-1 bg-green-600 text-white py-2 px-4 rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2">
128
+ <i class="fas fa-sign-in-alt mr-2"></i> Join
129
+ </button>
130
+ </div>
131
+ </div>
132
+ </div>
133
+
134
+ <!-- Call screen -->
135
+ <div id="call-screen" class="hidden">
136
+ <div class="bg-gray-800 text-white p-4 flex justify-between items-center">
137
+ <div class="flex items-center">
138
+ <i class="fas fa-video mr-2"></i>
139
+ <h2 id="current-room-id" class="font-semibold">Meeting ID: </h2>
140
+ </div>
141
+ <div class="flex items-center">
142
+ <span id="current-time" class="text-sm"></span>
143
+ </div>
144
+ </div>
145
+
146
+ <div id="video-grid" class="video-grid">
147
+ <!-- Video streams will be added here dynamically -->
148
+ </div>
149
+
150
+ <div class="controls">
151
+ <div class="control-btn bg-gray-200" id="toggle-mic" title="Mute/Unmute">
152
+ <i class="fas fa-microphone"></i>
153
+ </div>
154
+ <div class="control-btn bg-gray-200" id="toggle-video" title="Video On/Off">
155
+ <i class="fas fa-video"></i>
156
+ </div>
157
+ <div class="control-btn bg-blue-500 text-white" id="share-screen" title="Share Screen">
158
+ <i class="fas fa-desktop"></i>
159
+ </div>
160
+ <div class="control-btn bg-gray-200" id="participants" title="Participants">
161
+ <i class="fas fa-users"></i>
162
+ </div>
163
+ <div class="control-btn end-call" id="end-call" title="End Call">
164
+ <i class="fas fa-phone-slash"></i>
165
+ </div>
166
+ </div>
167
+ </div>
168
+
169
+ <!-- Participants modal -->
170
+ <div id="participants-modal" class="modal">
171
+ <div class="modal-content">
172
+ <div class="flex justify-between items-center mb-4">
173
+ <h3 class="text-lg font-semibold">Participants</h3>
174
+ <button id="close-participants" class="text-gray-500 hover:text-gray-700">
175
+ <i class="fas fa-times"></i>
176
+ </button>
177
+ </div>
178
+ <ul id="participants-list" class="divide-y divide-gray-200">
179
+ <!-- Participants will be added here -->
180
+ </ul>
181
+ </div>
182
+ </div>
183
+
184
+ <script>
185
+ // DOM elements
186
+ const preCallScreen = document.getElementById('pre-call');
187
+ const callScreen = document.getElementById('call-screen');
188
+ const roomIdInput = document.getElementById('room-id');
189
+ const userNameInput = document.getElementById('user-name');
190
+ const newMeetingBtn = document.getElementById('new-meeting');
191
+ const joinMeetingBtn = document.getElementById('join-meeting');
192
+ const videoGrid = document.getElementById('video-grid');
193
+ const toggleMicBtn = document.getElementById('toggle-mic');
194
+ const toggleVideoBtn = document.getElementById('toggle-video');
195
+ const endCallBtn = document.getElementById('end-call');
196
+ const shareScreenBtn = document.getElementById('share-screen');
197
+ const participantsBtn = document.getElementById('participants');
198
+ const currentRoomId = document.getElementById('current-room-id');
199
+ const currentTime = document.getElementById('current-time');
200
+ const participantsModal = document.getElementById('participants-modal');
201
+ const closeParticipantsBtn = document.getElementById('close-participants');
202
+ const participantsList = document.getElementById('participants-list');
203
+
204
+ // App state
205
+ let roomId = '';
206
+ let userName = '';
207
+ let localStream;
208
+ let peerConnections = {};
209
+ let isMicOn = true;
210
+ let isVideoOn = true;
211
+ let isScreenSharing = false;
212
+ let participants = {};
213
+ let callStartTime;
214
+ let socket;
215
+
216
+ // Configuration (in a real app, you'd use your own signaling server)
217
+ const configuration = {
218
+ iceServers: [
219
+ { urls: 'stun:stun.l.google.com:19302' },
220
+ { urls: 'stun:stun1.l.google.com:19302' },
221
+ { urls: 'stun:stun2.l.google.com:19302' }
222
+ ]
223
+ };
224
+
225
+ // Generate a random room ID if not provided
226
+ function generateRoomId() {
227
+ return Math.random().toString(36).substring(2, 8).toUpperCase();
228
+ }
229
+
230
+ // Update the current time display
231
+ function updateCurrentTime() {
232
+ const now = new Date();
233
+ currentTime.textContent = now.toLocaleTimeString();
234
+
235
+ if (callStartTime) {
236
+ const duration = Math.floor((now - callStartTime) / 1000);
237
+ const hours = Math.floor(duration / 3600);
238
+ const minutes = Math.floor((duration % 3600) / 60);
239
+ const seconds = duration % 60;
240
+
241
+ document.getElementById('call-duration')?.textContent =
242
+ `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
243
+ }
244
+ }
245
+
246
+ // Add a video stream to the grid
247
+ function addVideoStream(userId, stream, name, isLocal = false) {
248
+ if (document.getElementById(`video-${userId}`)) return;
249
+
250
+ const videoContainer = document.createElement('div');
251
+ videoContainer.className = 'video-item';
252
+ videoContainer.id = `container-${userId}`;
253
+
254
+ const videoElement = document.createElement('video');
255
+ videoElement.id = `video-${userId}`;
256
+ videoElement.autoplay = true;
257
+ videoElement.playsInline = true;
258
+ videoElement.srcObject = stream;
259
+
260
+ if (isLocal) {
261
+ videoElement.muted = true;
262
+ videoElement.id = 'local-video';
263
+ }
264
+
265
+ const videoInfo = document.createElement('div');
266
+ videoInfo.className = 'video-info';
267
+ videoInfo.innerHTML = `
268
+ <span>${name}</span>
269
+ ${isLocal ? '<span class="float-right">(You)</span>' : ''}
270
+ `;
271
+
272
+ videoContainer.appendChild(videoElement);
273
+ videoContainer.appendChild(videoInfo);
274
+ videoGrid.appendChild(videoContainer);
275
+
276
+ // Add to participants list
277
+ participants[userId] = { name, stream, audio: true, video: true };
278
+ updateParticipantsList();
279
+
280
+ // Adjust video grid layout
281
+ adjustVideoGrid();
282
+ }
283
+
284
+ // Adjust video grid layout based on number of participants
285
+ function adjustVideoGrid() {
286
+ const participantCount = Object.keys(participants).length;
287
+
288
+ if (participantCount === 1) {
289
+ videoGrid.style.gridTemplateColumns = '1fr';
290
+ } else if (participantCount === 2) {
291
+ videoGrid.style.gridTemplateColumns = '1fr 1fr';
292
+ } else if (participantCount <= 4) {
293
+ videoGrid.style.gridTemplateColumns = '1fr 1fr';
294
+ } else {
295
+ videoGrid.style.gridTemplateColumns = 'repeat(auto-fill, minmax(300px, 1fr))';
296
+ }
297
+ }
298
+
299
+ // Remove a video stream from the grid
300
+ function removeVideoStream(userId) {
301
+ const videoContainer = document.getElementById(`container-${userId}`);
302
+ if (videoContainer) {
303
+ videoContainer.remove();
304
+ delete participants[userId];
305
+ updateParticipantsList();
306
+ adjustVideoGrid();
307
+ }
308
+ }
309
+
310
+ // Update participants list in the modal
311
+ function updateParticipantsList() {
312
+ participantsList.innerHTML = '';
313
+
314
+ Object.entries(participants).forEach(([userId, participant]) => {
315
+ const li = document.createElement('li');
316
+ li.className = 'py-2 flex items-center';
317
+ li.innerHTML = `
318
+ <div class="flex-shrink-0 h-10 w-10 rounded-full bg-gray-300 flex items-center justify-center mr-3">
319
+ <i class="fas fa-user text-gray-600"></i>
320
+ </div>
321
+ <div class="flex-1 min-w-0">
322
+ <p class="text-sm font-medium text-gray-900 truncate">${participant.name}</p>
323
+ <p class="text-sm text-gray-500 truncate">${userId === 'local' ? 'Host' : 'Participant'}</p>
324
+ </div>
325
+ <div class="flex items-center">
326
+ <span class="w-2 h-2 rounded-full ${participant.audio ? 'bg-green-500' : 'bg-red-500'} mr-1"></span>
327
+ <i class="fas ${participant.video ? 'fa-video' : 'fa-video-slash'} text-sm ${participant.video ? 'text-green-500' : 'text-red-500'}"></i>
328
+ </div>
329
+ `;
330
+ participantsList.appendChild(li);
331
+ });
332
+ }
333
+
334
+ // Toggle microphone
335
+ async function toggleMic() {
336
+ isMicOn = !isMicOn;
337
+
338
+ if (localStream) {
339
+ const audioTracks = localStream.getAudioTracks();
340
+ audioTracks.forEach(track => {
341
+ track.enabled = isMicOn;
342
+ });
343
+ }
344
+
345
+ if (isMicOn) {
346
+ toggleMicBtn.innerHTML = '<i class="fas fa-microphone"></i>';
347
+ toggleMicBtn.classList.remove('muted');
348
+ } else {
349
+ toggleMicBtn.innerHTML = '<i class="fas fa-microphone-slash"></i>';
350
+ toggleMicBtn.classList.add('muted');
351
+ }
352
+
353
+ // Update participant status
354
+ if (participants['local']) {
355
+ participants['local'].audio = isMicOn;
356
+ updateParticipantsList();
357
+ }
358
+
359
+ // Send mute/unmute status to other participants (in a real app)
360
+ }
361
+
362
+ // Toggle video
363
+ async function toggleVideo() {
364
+ isVideoOn = !isVideoOn;
365
+
366
+ if (localStream) {
367
+ const videoTracks = localStream.getVideoTracks();
368
+ videoTracks.forEach(track => {
369
+ track.enabled = isVideoOn;
370
+ });
371
+ }
372
+
373
+ if (isVideoOn) {
374
+ toggleVideoBtn.innerHTML = '<i class="fas fa-video"></i>';
375
+ toggleVideoBtn.classList.remove('video-off');
376
+ } else {
377
+ toggleVideoBtn.innerHTML = '<i class="fas fa-video-slash"></i>';
378
+ toggleVideoBtn.classList.add('video-off');
379
+ }
380
+
381
+ // Update participant status
382
+ if (participants['local']) {
383
+ participants['local'].video = isVideoOn;
384
+ updateParticipantsList();
385
+ }
386
+
387
+ // Send video on/off status to other participants (in a real app)
388
+ }
389
+
390
+ // Share screen
391
+ async function shareScreen() {
392
+ try {
393
+ if (isScreenSharing) {
394
+ // Stop screen sharing and switch back to camera
395
+ const videoTrack = await getCameraStream();
396
+ replaceStreamTrack(videoTrack);
397
+
398
+ isScreenSharing = false;
399
+ shareScreenBtn.classList.remove('bg-blue-500', 'text-white');
400
+ shareScreenBtn.classList.add('bg-gray-200');
401
+ } else {
402
+ // Get screen stream
403
+ const screenStream = await navigator.mediaDevices.getDisplayMedia({
404
+ video: true,
405
+ audio: false
406
+ });
407
+
408
+ // Replace video track with screen share
409
+ const videoTrack = screenStream.getVideoTracks()[0];
410
+ replaceStreamTrack(videoTrack);
411
+
412
+ isScreenSharing = true;
413
+ shareScreenBtn.classList.add('bg-blue-500', 'text-white');
414
+ shareScreenBtn.classList.remove('bg-gray-200');
415
+
416
+ // Handle when user stops screen sharing
417
+ videoTrack.onended = () => {
418
+ shareScreen();
419
+ };
420
+ }
421
+ } catch (err) {
422
+ console.error('Error sharing screen:', err);
423
+ }
424
+ }
425
+
426
+ // Get camera stream
427
+ async function getCameraStream() {
428
+ const stream = await navigator.mediaDevices.getUserMedia({
429
+ video: {
430
+ width: { ideal: 1280 },
431
+ height: { ideal: 720 },
432
+ frameRate: { ideal: 30 }
433
+ },
434
+ audio: true
435
+ });
436
+ return stream.getVideoTracks()[0];
437
+ }
438
+
439
+ // Replace the video track in the local stream
440
+ function replaceStreamTrack(newTrack) {
441
+ const videoTracks = localStream.getVideoTracks();
442
+ const sender = getPeerConnectionSender('video');
443
+
444
+ if (sender) {
445
+ sender.replaceTrack(newTrack);
446
+ }
447
+
448
+ // Replace the track in the local stream
449
+ videoTracks.forEach(track => track.stop());
450
+ localStream.removeTrack(videoTracks[0]);
451
+ localStream.addTrack(newTrack);
452
+
453
+ // Update the local video element
454
+ const videoElement = document.getElementById('local-video');
455
+ if (videoElement) {
456
+ videoElement.srcObject = localStream;
457
+ }
458
+ }
459
+
460
+ // Get the RTCRtpSender for a specific track type
461
+ function getPeerConnectionSender(type) {
462
+ for (const pc of Object.values(peerConnections)) {
463
+ const senders = pc.getSenders();
464
+ const sender = senders.find(s => s.track && s.track.kind === type);
465
+ if (sender) return sender;
466
+ }
467
+ return null;
468
+ }
469
+
470
+ // Initialize WebRTC peer connections
471
+ async function initializePeerConnection(userId) {
472
+ const peerConnection = new RTCPeerConnection(configuration);
473
+ peerConnections[userId] = peerConnection;
474
+
475
+ // Add local stream tracks to peer connection
476
+ localStream.getTracks().forEach(track => {
477
+ peerConnection.addTrack(track, localStream);
478
+ });
479
+
480
+ // Handle ICE candidates
481
+ peerConnection.onicecandidate = event => {
482
+ if (event.candidate) {
483
+ // Send the ICE candidate to the remote peer (via signaling server)
484
+ console.log('Sending ICE candidate:', event.candidate);
485
+ }
486
+ };
487
+
488
+ // Handle remote stream
489
+ peerConnection.ontrack = event => {
490
+ const remoteStream = event.streams[0];
491
+ addVideoStream(userId, remoteStream, `User ${userId}`);
492
+ };
493
+
494
+ // Handle connection state changes
495
+ peerConnection.onconnectionstatechange = () => {
496
+ console.log(`Connection state with ${userId}:`, peerConnection.connectionState);
497
+ if (peerConnection.connectionState === 'disconnected' ||
498
+ peerConnection.connectionState === 'failed') {
499
+ removeVideoStream(userId);
500
+ delete peerConnections[userId];
501
+ }
502
+ };
503
+
504
+ return peerConnection;
505
+ }
506
+
507
+ // Start a new call
508
+ async function startCall(isNewMeeting = true) {
509
+ userName = userNameInput.value.trim();
510
+ roomId = roomIdInput.value.trim();
511
+
512
+ if (!userName) {
513
+ alert('Please enter your name');
514
+ return;
515
+ }
516
+
517
+ if (!roomId && isNewMeeting) {
518
+ roomId = generateRoomId();
519
+ roomIdInput.value = roomId;
520
+ } else if (!roomId) {
521
+ alert('Please enter a meeting ID');
522
+ return;
523
+ }
524
+
525
+ try {
526
+ // Get user media
527
+ localStream = await navigator.mediaDevices.getUserMedia({
528
+ video: {
529
+ width: { ideal: 1280 },
530
+ height: { ideal: 720 },
531
+ frameRate: { ideal: 30 }
532
+ },
533
+ audio: true
534
+ });
535
+
536
+ // Show call screen
537
+ preCallScreen.classList.add('hidden');
538
+ callScreen.classList.remove('hidden');
539
+
540
+ // Update room ID display
541
+ currentRoomId.textContent = `Meeting ID: ${roomId}`;
542
+
543
+ // Add local video
544
+ addVideoStream('local', localStream, userName, true);
545
+
546
+ // Start call timer
547
+ callStartTime = new Date();
548
+ setInterval(updateCurrentTime, 1000);
549
+ updateCurrentTime();
550
+
551
+ // In a real app, you would connect to a signaling server here
552
+ // and initialize peer connections with other participants
553
+ console.log('Call started. In a real app, you would connect to a signaling server.');
554
+
555
+ } catch (err) {
556
+ console.error('Error starting call:', err);
557
+ alert('Could not access camera or microphone. Please check permissions.');
558
+ endCall();
559
+ }
560
+ }
561
+
562
+ // End the call
563
+ function endCall() {
564
+ // Stop all media tracks
565
+ if (localStream) {
566
+ localStream.getTracks().forEach(track => track.stop());
567
+ }
568
+
569
+ // Close all peer connections
570
+ Object.values(peerConnections).forEach(pc => pc.close());
571
+ peerConnections = {};
572
+
573
+ // Reset state
574
+ localStream = null;
575
+ participants = {};
576
+ callStartTime = null;
577
+
578
+ // Clear video grid
579
+ videoGrid.innerHTML = '';
580
+
581
+ // Hide call screen
582
+ callScreen.classList.add('hidden');
583
+ preCallScreen.classList.remove('hidden');
584
+
585
+ // Close any open modals
586
+ participantsModal.style.display = 'none';
587
+
588
+ // Reset controls
589
+ isMicOn = true;
590
+ isVideoOn = true;
591
+ isScreenSharing = false;
592
+
593
+ toggleMicBtn.innerHTML = '<i class="fas fa-microphone"></i>';
594
+ toggleMicBtn.classList.remove('muted');
595
+
596
+ toggleVideoBtn.innerHTML = '<i class="fas fa-video"></i>';
597
+ toggleVideoBtn.classList.remove('video-off');
598
+
599
+ shareScreenBtn.classList.remove('bg-blue-500', 'text-white');
600
+ shareScreenBtn.classList.add('bg-gray-200');
601
+ }
602
+
603
+ // Event listeners
604
+ newMeetingBtn.addEventListener('click', () => startCall(true));
605
+ joinMeetingBtn.addEventListener('click', () => startCall(false));
606
+
607
+ toggleMicBtn.addEventListener('click', toggleMic);
608
+ toggleVideoBtn.addEventListener('click', toggleVideo);
609
+ endCallBtn.addEventListener('click', endCall);
610
+ shareScreenBtn.addEventListener('click', shareScreen);
611
+
612
+ participantsBtn.addEventListener('click', () => {
613
+ participantsModal.style.display = 'flex';
614
+ });
615
+
616
+ closeParticipantsBtn.addEventListener('click', () => {
617
+ participantsModal.style.display = 'none';
618
+ });
619
+
620
+ // Initialize with a random name if field is empty
621
+ if (!userNameInput.value) {
622
+ const names = ['Alex', 'Jamie', 'Taylor', 'Jordan', 'Casey', 'Riley'];
623
+ userNameInput.value = names[Math.floor(Math.random() * names.length)];
624
+ }
625
+
626
+ // Check for room ID in URL
627
+ const urlParams = new URLSearchParams(window.location.search);
628
+ const roomParam = urlParams.get('room');
629
+
630
+ if (roomParam) {
631
+ roomIdInput.value = roomParam;
632
+ }
633
+ </script>
634
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Samir621/connecthub" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
635
+ </html>