freddyaboulton HF Staff commited on
Commit
1e421f2
·
verified ·
1 Parent(s): 1dd46a8

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +47 -0
index.html CHANGED
@@ -140,6 +140,30 @@
140
  .nav-button:hover {
141
  background-color: #1565c0;
142
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  </style>
144
  </head>
145
 
@@ -183,6 +207,8 @@
183
  <audio id="webrtc-audio" style="display: none;"></audio>
184
  <audio id="ws-audio" style="display: none;"></audio>
185
 
 
 
186
  <script>
187
  // Shared utilities
188
  function generateId() {
@@ -249,6 +275,18 @@
249
  webrtcPeerConnection = new RTCPeerConnection(config);
250
  const webrtcId = generateId();
251
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  try {
253
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
254
  stream.getTracks().forEach(track => {
@@ -309,7 +347,16 @@
309
  // Store the interval ID on the connection
310
  webrtcPeerConnection.statsInterval = statsInterval;
311
 
 
 
 
 
 
 
 
 
312
  } catch (err) {
 
313
  console.error('WebRTC setup error:', err);
314
  }
315
  }
 
140
  .nav-button:hover {
141
  background-color: #1565c0;
142
  }
143
+
144
+ /* Add styles for toast notifications */
145
+ .toast {
146
+ position: fixed;
147
+ top: 20px;
148
+ left: 50%;
149
+ transform: translateX(-50%);
150
+ padding: 16px 24px;
151
+ border-radius: 4px;
152
+ font-size: 14px;
153
+ z-index: 1000;
154
+ display: none;
155
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
156
+ }
157
+
158
+ .toast.error {
159
+ background-color: #f44336;
160
+ color: white;
161
+ }
162
+
163
+ .toast.warning {
164
+ background-color: #ffd700;
165
+ color: black;
166
+ }
167
  </style>
168
  </head>
169
 
 
207
  <audio id="webrtc-audio" style="display: none;"></audio>
208
  <audio id="ws-audio" style="display: none;"></audio>
209
 
210
+ <div id="error-toast" class="toast"></div>
211
+
212
  <script>
213
  // Shared utilities
214
  function generateId() {
 
275
  webrtcPeerConnection = new RTCPeerConnection(config);
276
  const webrtcId = generateId();
277
 
278
+ const timeoutId = setTimeout(() => {
279
+ const toast = document.getElementById('error-toast');
280
+ toast.textContent = "Connection is taking longer than usual. Are you on a VPN?";
281
+ toast.className = 'toast warning';
282
+ toast.style.display = 'block';
283
+
284
+ // Hide warning after 5 seconds
285
+ setTimeout(() => {
286
+ toast.style.display = 'none';
287
+ }, 5000);
288
+ }, 5000);
289
+
290
  try {
291
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
292
  stream.getTracks().forEach(track => {
 
347
  // Store the interval ID on the connection
348
  webrtcPeerConnection.statsInterval = statsInterval;
349
 
350
+ webrtcPeerConnection.addEventListener('connectionstatechange', () => {
351
+ if (webrtcPeerConnection.connectionState === 'connected') {
352
+ clearTimeout(timeoutId);
353
+ const toast = document.getElementById('error-toast');
354
+ toast.style.display = 'none';
355
+ }
356
+ });
357
+
358
  } catch (err) {
359
+ clearTimeout(timeoutId);
360
  console.error('WebRTC setup error:', err);
361
  }
362
  }