Skip to content

Commit

Permalink
remove first line define plugin and set videocallback to null and vid…
Browse files Browse the repository at this point in the history
…eo initialized
  • Loading branch information
YushraJewon committed Jul 16, 2024
1 parent 3594f47 commit 9667c56
Showing 1 changed file with 72 additions and 70 deletions.
142 changes: 72 additions & 70 deletions www/SimpleCameraPreview.js
Original file line number Diff line number Diff line change
@@ -1,79 +1,81 @@
cordova.define("@spoonconsulting/cordova-plugin-simple-camera-preview.SimpleCameraPreview", function(require, exports, module) {
var exec = require("cordova/exec");
var PLUGIN_NAME = "SimpleCameraPreview";
var SimpleCameraPreview = function () {};

SimpleCameraPreview.setOptions = function (options, onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "setOptions", [options]);
};

SimpleCameraPreview.enable = function (options, onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "enable", [options]);
};

SimpleCameraPreview.disable = function (onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "disable", []);
};

SimpleCameraPreview.startVideoCapture = function (onSuccess, onError) {
if (!SimpleCameraPreview.videoCallback) {
console.error("Call setVideoCallback first");
onError("Call setVideoCallback first");
return;
}

if (!SimpleCameraPreview.videoInitialized) {
exec(
(info) => {
SimpleCameraPreview.videoInitialized = true;
this.videoCallback(info);
} ,
(err) => {
console.log("Error initializing video callback", err);
},
"SimpleCameraPreview",
"initVideoCallback",
[]
);
}
exec(onSuccess, onError, PLUGIN_NAME, "startVideoCapture");
};

SimpleCameraPreview.setVideoCallback = function (callback) {
this.videoCallback = callback;
var exec = require("cordova/exec");
var PLUGIN_NAME = "SimpleCameraPreview";
var SimpleCameraPreview = function () {};

SimpleCameraPreview.videoInitialized = false;
SimpleCameraPreview.videoCallback = null;

SimpleCameraPreview.startVideoCapture = function (onSuccess, onError) {
if (!SimpleCameraPreview.videoCallback) {
console.error("Call setVideoCallback first");
onError("Call setVideoCallback first");
return;
}

SimpleCameraPreview.capture = function (options, onSuccess, onError) {
options = options || {};
options.flash = options.flash || false;
exec(onSuccess, onError, PLUGIN_NAME, "capture", [options.flash]);
};
if (!SimpleCameraPreview.videoInitialized) {
exec(
(info) => {
SimpleCameraPreview.videoInitialized = true;
this.videoCallback(info);
} ,
(err) => {
console.log("Error initializing video callback", err);
},
"SimpleCameraPreview",
"initVideoCallback",
[]
);
}
exec(onSuccess, onError, PLUGIN_NAME, "startVideoCapture");
};

SimpleCameraPreview.stopVideoCapture = function (onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "stopVideoCapture");
};

SimpleCameraPreview.setVideoCallback = function (callback) {
this.videoCallback = callback;
}

SimpleCameraPreview.setOptions = function (options, onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "setOptions", [options]);
};

SimpleCameraPreview.enable = function (options, onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "enable", [options]);
};

SimpleCameraPreview.disable = function (onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "disable", []);
};

SimpleCameraPreview.capture = function (options, onSuccess, onError) {
options = options || {};
options.flash = options.flash || false;
exec(onSuccess, onError, PLUGIN_NAME, "capture", [options.flash]);
};

SimpleCameraPreview.stopVideoCapture = function (onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "stopVideoCapture");
};
SimpleCameraPreview.setSize = function (options, onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "setSize", [options]);
};

SimpleCameraPreview.setSize = function (options, onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "setSize", [options]);
};
SimpleCameraPreview.torchSwitch = function (options, onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "torchSwitch", [options]);
};

SimpleCameraPreview.torchSwitch = function (options, onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "torchSwitch", [options]);
};
SimpleCameraPreview.switchCameraTo = function (options, onSuccess, onError) {
options = options || {};
options.captureDevice = options.captureDevice || "default";
exec(onSuccess, onError, PLUGIN_NAME, "switchCameraTo", [options.captureDevice]);
};

SimpleCameraPreview.switchCameraTo = function (options, onSuccess, onError) {
options = options || {};
options.captureDevice = options.captureDevice || "default";
exec(onSuccess, onError, PLUGIN_NAME, "switchCameraTo", [options.captureDevice]);
};
SimpleCameraPreview.deviceHasFlash = function (onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "deviceHasFlash", []);
};

SimpleCameraPreview.deviceHasFlash = function (onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "deviceHasFlash", []);
};
SimpleCameraPreview.deviceHasUltraWideCamera = function (onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "deviceHasUltraWideCamera", []);
};

SimpleCameraPreview.deviceHasUltraWideCamera = function (onSuccess, onError) {
exec(onSuccess, onError, PLUGIN_NAME, "deviceHasUltraWideCamera", []);
};
module.exports = SimpleCameraPreview;

module.exports = SimpleCameraPreview;
});

0 comments on commit 9667c56

Please sign in to comment.