-
-
Save parzibyte/c79d42201abbc2f936c347c15ad242d8 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
//Escuchar el click del botón para tomar la foto | |
$boton.addEventListener("click", function() { | |
//Pausar reproducción | |
$video.pause(); | |
//Obtener contexto del canvas y dibujar sobre él | |
let contexto = $canvas.getContext("2d"); | |
$canvas.width = $video.videoWidth; | |
$canvas.height = $video.videoHeight; | |
contexto.drawImage($video, 0, 0, $canvas.width, $canvas.height); | |
let foto = $canvas.toDataURL(); //Esta es la foto, en base 64 | |
let enlace = document.createElement('a'); // Crear un <a> | |
enlace.download = "foto_parzibyte.me.png"; | |
enlace.href = foto; | |
enlace.click(); | |
//Reanudar reproducción | |
$video.play(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment