-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove first line define plugin and set videocallback to null and vid…
…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.
There are no files selected for viewing
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
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; | ||
}); |