Image Capture

What's the recommend approach for taking photos in the browser? Is the
image capture API dead?

The code is squashed up onto one line. See:—

http://w3c.github.io/mediacapture-image/#taking-a-picture-if-red-eye-reduction-is-activated

navigator.getUserMedia({video: true}, gotMedia, failedToGetMedia);

function gotMedia(mediastream) {
   //Extract video track.
   var videoDevice = mediastream.getVideoTracks()[0];
   // Check if this device supports a picture mode...
   var captureDevice = new ImageCapture(videoDevice);
   if (captureDevice) {
         if (captureDevice.photoCapabilities.redEyeReduction) {
            captureDevice.setOptions({redEyeReductionSetting:true}).then(captureDevice.takePhoto().then(showPicture(blob),function(error){alert("Failed
to take photo");}));
            }
         else
            console.log('No red eye reduction');
         }
     }

 function showPicture(e) {
    var img = document.querySelector("img");
    img.src = URL.createObjectURL(e.data);
    }

 function failedToGetMedia{
    console.log('Stream failure');
    }



I see an incomplete example with a line that looks well over 150 chars
wide, an unclosed function, console.log statements, and continuation
of the promises trend as realized in the API. And it will still throw
errors even if the SyntaxErrors are cleaned up.

Slow, buggy wrapper libraries should not be used to save developers
from the n complexity of browser implementations over APIs. Instead,
APIs should be designed so that libraries are not needed.

Can taking a photo require a low degree of complexity? E.g. a method
call with a callback and an error handler. How does it work?

Thank you,
-- 
Garrett
@xkit
ChordCycles.wordpress.com
garretts.github.io
personx.tumblr.com

Received on Saturday, 30 January 2016 20:55:40 UTC