Last active
October 15, 2019 03:59
-
-
Save GitHub30/8a6ffa719f3e7c2b44e657947abe5364 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
function takePhoto(video, mimeType = 'image/jpeg') { | |
return new Promise(resolve => { | |
video.animate({opacity: [0,1]}, 300); | |
const canvas = document.createElement('canvas'); | |
canvas.width = video.videoWidth; | |
canvas.height = video.videoHeight; | |
// TODO | |
// https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext | |
// https://bugzilla.mozilla.org/show_bug.cgi?id=801176 | |
canvas.getContext('2d').drawImage(video, 0, 0); | |
canvas.toBlob(resolve, mimeType); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment