Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var limit = options.limit || 1;
if (typeof limit !== 'number' || limit < 1) {
fail(CaptureError.CAPTURE_INVALID_ARGUMENT);
return;
}
// Counter for already taken images
var imagesTaken = 0;
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
if (!navigator.getUserMedia) {
fail(CaptureError.CAPTURE_NOT_SUPPORTED);
return;
}
var ui = new CameraUI();
ui.startPreview(limit, function (data) {
// Check if we're done with capture. If so, then destroy UI
if (++imagesTaken >= limit) {
ui.destroyPreview();
}
// Array of resultant MediaFiles
var mediaFiles = [];
// save data to file here
window.requestFileSystem(window.TEMPORARY, data.length * limit, function (fileSystem) {
// If we need to capture multiple files, then append counter to filename
captureVideo: function (successCallback, errorCallback) {
if (errorCallback) {
errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED));
}
},