Felguk commited on
Commit
b1303c6
·
verified ·
1 Parent(s): dbf0b1b

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +77 -1
index.html CHANGED
@@ -130,7 +130,8 @@
130
  }
131
 
132
  .card-preview img,
133
- .card-preview audio {
 
134
  max-width: 100%;
135
  border-radius: 10px;
136
  }
@@ -286,6 +287,7 @@
286
  <button class="btn glow" onclick="showTool('cardMaker')">Card Maker <i class="fas fa-paint-brush"></i></button>
287
  <button class="btn glow" onclick="showTool('imageVideoToCard')">Image/Video to Card <i class="fas fa-image"></i></button>
288
  <button class="btn glow" onclick="showTool('history')">History <i class="fas fa-history"></i></button>
 
289
  </div>
290
 
291
  <!-- Card Maker Section -->
@@ -334,6 +336,18 @@
334
  <button class="btn" onclick="downloadGeneratedPDF()">Download PDF <i class="fas fa-file-pdf"></i></button>
335
  </div>
336
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  <!-- History Section -->
338
  <div id="history" class="container hidden fade-in">
339
  <h1>History</h1>
@@ -349,6 +363,11 @@
349
  // Массив для хранения истории карточек
350
  let history = [];
351
 
 
 
 
 
 
352
  // Функция для переключения между инструментами
353
  function showTool(toolId) {
354
  // Скрыть все инструменты
@@ -367,6 +386,63 @@
367
  if (toolId === 'history') {
368
  updateHistory();
369
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
  }
371
 
372
  // Сохранить карточку в историю
 
130
  }
131
 
132
  .card-preview img,
133
+ .card-preview audio,
134
+ .card-preview video {
135
  max-width: 100%;
136
  border-radius: 10px;
137
  }
 
287
  <button class="btn glow" onclick="showTool('cardMaker')">Card Maker <i class="fas fa-paint-brush"></i></button>
288
  <button class="btn glow" onclick="showTool('imageVideoToCard')">Image/Video to Card <i class="fas fa-image"></i></button>
289
  <button class="btn glow" onclick="showTool('history')">History <i class="fas fa-history"></i></button>
290
+ <button class="btn glow" onclick="showTool('videoRecorder')">Video Recorder <i class="fas fa-video"></i></button>
291
  </div>
292
 
293
  <!-- Card Maker Section -->
 
336
  <button class="btn" onclick="downloadGeneratedPDF()">Download PDF <i class="fas fa-file-pdf"></i></button>
337
  </div>
338
 
339
+ <!-- Video Recorder Section -->
340
+ <div id="videoRecorder" class="container hidden fade-in">
341
+ <h1>Video Recorder</h1>
342
+ <div class="card">
343
+ <video id="videoPreview" autoplay muted style="max-width: 100%; border-radius: 10px;"></video>
344
+ <div class="card-preview" id="recordedVideoPreview"></div>
345
+ <button class="btn" id="startRecording" onclick="startRecording()">Start Recording <i class="fas fa-circle"></i></button>
346
+ <button class="btn" id="stopRecording" onclick="stopRecording()" disabled>Stop Recording <i class="fas fa-stop"></i></button>
347
+ <button class="btn" onclick="downloadRecordedVideo()" id="downloadRecordedVideo" disabled>Download Video <i class="fas fa-download"></i></button>
348
+ </div>
349
+ </div>
350
+
351
  <!-- History Section -->
352
  <div id="history" class="container hidden fade-in">
353
  <h1>History</h1>
 
363
  // Массив для хранения истории карточек
364
  let history = [];
365
 
366
+ // Переменные для записи видео
367
+ let mediaRecorder;
368
+ let recordedChunks = [];
369
+ let recordedVideoUrl;
370
+
371
  // Функция для переключения между инструментами
372
  function showTool(toolId) {
373
  // Скрыть все инструменты
 
386
  if (toolId === 'history') {
387
  updateHistory();
388
  }
389
+
390
+ // Если открыт видеорекордер, инициализировать камеру
391
+ if (toolId === 'videoRecorder') {
392
+ initVideoRecorder();
393
+ }
394
+ }
395
+
396
+ // Инициализация видеорекордера
397
+ async function initVideoRecorder() {
398
+ try {
399
+ const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
400
+ const videoPreview = document.getElementById('videoPreview');
401
+ videoPreview.srcObject = stream;
402
+
403
+ mediaRecorder = new MediaRecorder(stream, { mimeType: 'video/webm; codecs=vp9' });
404
+
405
+ mediaRecorder.ondataavailable = (event) => {
406
+ if (event.data.size > 0) {
407
+ recordedChunks.push(event.data);
408
+ }
409
+ };
410
+
411
+ mediaRecorder.onstop = () => {
412
+ const blob = new Blob(recordedChunks, { type: 'video/webm' });
413
+ recordedVideoUrl = URL.createObjectURL(blob);
414
+ const recordedVideoPreview = document.getElementById('recordedVideoPreview');
415
+ recordedVideoPreview.innerHTML = `<video controls src="${recordedVideoUrl}" style="max-width: 100%; border-radius: 10px;"></video>`;
416
+ document.getElementById('downloadRecordedVideo').disabled = false;
417
+ };
418
+ } catch (error) {
419
+ console.error('Error accessing media devices:', error);
420
+ alert('Error accessing camera or microphone. Please ensure you have granted the necessary permissions.');
421
+ }
422
+ }
423
+
424
+ // Начать запись
425
+ function startRecording() {
426
+ recordedChunks = [];
427
+ mediaRecorder.start();
428
+ document.getElementById('startRecording').disabled = true;
429
+ document.getElementById('stopRecording').disabled = false;
430
+ document.getElementById('downloadRecordedVideo').disabled = true;
431
+ }
432
+
433
+ // Остановить запись
434
+ function stopRecording() {
435
+ mediaRecorder.stop();
436
+ document.getElementById('startRecording').disabled = false;
437
+ document.getElementById('stopRecording').disabled = true;
438
+ }
439
+
440
+ // Скачать записанное видео
441
+ function downloadRecordedVideo() {
442
+ const link = document.createElement('a');
443
+ link.href = recordedVideoUrl;
444
+ link.download = 'recorded-video.mp4';
445
+ link.click();
446
  }
447
 
448
  // Сохранить карточку в историю