-
-
Save parzibyte/c05670f2a63f52d7cbfd3b480a69ade1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cuando se detenga (haciendo click en el botón) se ejecuta esto | |
mediaRecorder.addEventListener("stop", () => { | |
// Pausar vídeo | |
$video.pause(); | |
// Detener el stream | |
stream.getTracks().forEach(track => track.stop()); | |
// Detener la cuenta regresiva | |
detenerConteo(); | |
// Convertir los fragmentos a un objeto binario | |
const blobVideo = new Blob(fragmentosDeAudio); | |
const formData = new FormData(); | |
// Enviar el BinaryLargeObject con FormData | |
formData.append("video", blobVideo); | |
const RUTA_SERVIDOR = "guardar.php"; | |
$duracion.textContent = "Enviando vídeo..."; | |
fetch(RUTA_SERVIDOR, { | |
method: "POST", | |
body: formData, | |
}) | |
.then(respuestaRaw => respuestaRaw.text()) // Decodificar como texto | |
.then(respuestaComoTexto => { | |
// Aquí haz algo con la respuesta ;) | |
console.log("La respuesta: ", respuestaComoTexto); | |
// Abrir el archivo, es opcional y solo lo pongo como demostración | |
$duracion.innerHTML = `<strong>Vídeo subido correctamente.</strong> <a target="_blank" href="${respuestaComoTexto}">Abrir</a>` | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment