Spaces:
Running
Running
Update index.html
Browse files- index.html +69 -1
index.html
CHANGED
@@ -307,6 +307,10 @@
|
|
307 |
<button class="btn" onclick="clearPreview('cardMakerPreview')">Delete this Card <i class="fas fa-trash"></i></button>
|
308 |
<button class="btn" onclick="downloadCardMakerImage()">Download Image <i class="fas fa-download"></i></button>
|
309 |
<button class="btn" onclick="downloadCardMakerPDF()">Download PDF <i class="fas fa-file-pdf"></i></button>
|
|
|
|
|
|
|
|
|
310 |
</div>
|
311 |
<div class="card-preview" id="cardMakerPreview"></div>
|
312 |
</div>
|
@@ -331,6 +335,10 @@
|
|
331 |
<button class="btn" onclick="clearPreview('generatedCardPreview')">Delete this Card <i class="fas fa-trash"></i></button>
|
332 |
<button class="btn" onclick="downloadGeneratedImage()">Download Image <i class="fas fa-download"></i></button>
|
333 |
<button class="btn" onclick="downloadGeneratedPDF()">Download PDF <i class="fas fa-file-pdf"></i></button>
|
|
|
|
|
|
|
|
|
334 |
</div>
|
335 |
<div class="card-preview" id="generatedCardPreview"></div>
|
336 |
</div>
|
@@ -350,6 +358,11 @@
|
|
350 |
// Массив для хранения истории карточек
|
351 |
let history = [];
|
352 |
|
|
|
|
|
|
|
|
|
|
|
353 |
// Функция для переключения между инструментами
|
354 |
function showTool(toolId) {
|
355 |
// Скрыть все инструменты
|
@@ -370,6 +383,61 @@
|
|
370 |
}
|
371 |
}
|
372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
// Сохранить карточку в историю
|
374 |
function saveCardToHistory(previewId) {
|
375 |
const cardPreview = document.getElementById(previewId).innerHTML;
|
@@ -512,4 +580,4 @@
|
|
512 |
}
|
513 |
</script>
|
514 |
</body>
|
515 |
-
</html>
|
|
|
307 |
<button class="btn" onclick="clearPreview('cardMakerPreview')">Delete this Card <i class="fas fa-trash"></i></button>
|
308 |
<button class="btn" onclick="downloadCardMakerImage()">Download Image <i class="fas fa-download"></i></button>
|
309 |
<button class="btn" onclick="downloadCardMakerPDF()">Download PDF <i class="fas fa-file-pdf"></i></button>
|
310 |
+
<!-- Кнопки для записи видео -->
|
311 |
+
<button class="btn" id="startRecordingCard" onclick="startRecording('cardMakerPreview')">Start Recording <i class="fas fa-circle"></i></button>
|
312 |
+
<button class="btn" id="stopRecordingCard" onclick="stopRecording('cardMakerPreview')" disabled>Stop Recording <i class="fas fa-stop"></i></button>
|
313 |
+
<button class="btn" id="downloadRecordedVideoCard" onclick="downloadRecordedVideo('cardMakerPreview')" disabled>Download MP4 <i class="fas fa-download"></i></button>
|
314 |
</div>
|
315 |
<div class="card-preview" id="cardMakerPreview"></div>
|
316 |
</div>
|
|
|
335 |
<button class="btn" onclick="clearPreview('generatedCardPreview')">Delete this Card <i class="fas fa-trash"></i></button>
|
336 |
<button class="btn" onclick="downloadGeneratedImage()">Download Image <i class="fas fa-download"></i></button>
|
337 |
<button class="btn" onclick="downloadGeneratedPDF()">Download PDF <i class="fas fa-file-pdf"></i></button>
|
338 |
+
<!-- Кнопки для записи видео -->
|
339 |
+
<button class="btn" id="startRecordingMedia" onclick="startRecording('generatedCardPreview')">Start Recording <i class="fas fa-circle"></i></button>
|
340 |
+
<button class="btn" id="stopRecordingMedia" onclick="stopRecording('generatedCardPreview')" disabled>Stop Recording <i class="fas fa-stop"></i></button>
|
341 |
+
<button class="btn" id="downloadRecordedVideoMedia" onclick="downloadRecordedVideo('generatedCardPreview')" disabled>Download MP4 <i class="fas fa-download"></i></button>
|
342 |
</div>
|
343 |
<div class="card-preview" id="generatedCardPreview"></div>
|
344 |
</div>
|
|
|
358 |
// Массив для хранения истории карточек
|
359 |
let history = [];
|
360 |
|
361 |
+
// Переменные для записи видео
|
362 |
+
let mediaRecorder;
|
363 |
+
let recordedChunks = [];
|
364 |
+
let recordedVideoUrl;
|
365 |
+
|
366 |
// Функция для переключения между инструментами
|
367 |
function showTool(toolId) {
|
368 |
// Скрыть все инструменты
|
|
|
383 |
}
|
384 |
}
|
385 |
|
386 |
+
// Инициализация видеорекордера
|
387 |
+
async function initVideoRecorder(previewId) {
|
388 |
+
try {
|
389 |
+
const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
|
390 |
+
const previewElement = document.getElementById(previewId);
|
391 |
+
previewElement.innerHTML = `<video id="videoPreview" autoplay muted style="max-width: 100%; border-radius: 10px;"></video>`;
|
392 |
+
const videoPreview = document.getElementById('videoPreview');
|
393 |
+
videoPreview.srcObject = stream;
|
394 |
+
|
395 |
+
mediaRecorder = new MediaRecorder(stream, { mimeType: 'video/webm; codecs=vp9' });
|
396 |
+
|
397 |
+
mediaRecorder.ondataavailable = (event) => {
|
398 |
+
if (event.data.size > 0) {
|
399 |
+
recordedChunks.push(event.data);
|
400 |
+
}
|
401 |
+
};
|
402 |
+
|
403 |
+
mediaRecorder.onstop = () => {
|
404 |
+
const blob = new Blob(recordedChunks, { type: 'video/webm' });
|
405 |
+
recordedVideoUrl = URL.createObjectURL(blob);
|
406 |
+
previewElement.innerHTML = `<video controls src="${recordedVideoUrl}" style="max-width: 100%; border-radius: 10px;"></video>`;
|
407 |
+
document.getElementById(`downloadRecordedVideo${previewId === 'cardMakerPreview' ? 'Card' : 'Media'}`).disabled = false;
|
408 |
+
};
|
409 |
+
} catch (error) {
|
410 |
+
console.error('Error accessing media devices:', error);
|
411 |
+
alert('Error accessing camera or microphone. Please ensure you have granted the necessary permissions.');
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
// Начать запись
|
416 |
+
function startRecording(previewId) {
|
417 |
+
recordedChunks = [];
|
418 |
+
initVideoRecorder(previewId).then(() => {
|
419 |
+
mediaRecorder.start();
|
420 |
+
document.getElementById(`startRecording${previewId === 'cardMakerPreview' ? 'Card' : 'Media'}`).disabled = true;
|
421 |
+
document.getElementById(`stopRecording${previewId === 'cardMakerPreview' ? 'Card' : 'Media'}`).disabled = false;
|
422 |
+
document.getElementById(`downloadRecordedVideo${previewId === 'cardMakerPreview' ? 'Card' : 'Media'}`).disabled = true;
|
423 |
+
});
|
424 |
+
}
|
425 |
+
|
426 |
+
// Остановить запись
|
427 |
+
function stopRecording(previewId) {
|
428 |
+
mediaRecorder.stop();
|
429 |
+
document.getElementById(`startRecording${previewId === 'cardMakerPreview' ? 'Card' : 'Media'}`).disabled = false;
|
430 |
+
document.getElementById(`stopRecording${previewId === 'cardMakerPreview' ? 'Card' : 'Media'}`).disabled = true;
|
431 |
+
}
|
432 |
+
|
433 |
+
// Скачать записанное видео
|
434 |
+
function downloadRecordedVideo(previewId) {
|
435 |
+
const link = document.createElement('a');
|
436 |
+
link.href = recordedVideoUrl;
|
437 |
+
link.download = 'recorded-video.mp4';
|
438 |
+
link.click();
|
439 |
+
}
|
440 |
+
|
441 |
// Сохранить карточку в историю
|
442 |
function saveCardToHistory(previewId) {
|
443 |
const cardPreview = document.getElementById(previewId).innerHTML;
|
|
|
580 |
}
|
581 |
</script>
|
582 |
</body>
|
583 |
+
</html>
|