cordova-plugin-camera-preview
Advanced tools
Comparing version 0.11.2 to 0.12.0
# Changelog | ||
## MASTER BRANCH (RECOMMENDED) - UNRELEASED | ||
- Nothing Yet | ||
- Nothing yet | ||
## v0.11.2 - February 12, 2020 - LATEST RELEASED VERSION | ||
## v0.12.0 - May 4, 2020 - LATEST RELEASED VERSION | ||
- [PR #605](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/pull/605) - Improve memory usage when capturing multiple photos for both Android and iOS | ||
- [PR #587](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/pull/587) - Add video recording functionality for Android | ||
- [PR #599](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/pull/599) - Use androidx package instead of legacy android support package | ||
- [PR #606](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/pull/606) - Remove `android:required` from manifest to avoid conflict with other plugins | ||
## v0.11.2 - February 12, 2020 | ||
- [PR #582](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/pull/582) - Add support for Android devices without Autofocus which can increase the amount of devices for which app installation is allowed by about (~4k at time of) | ||
@@ -8,0 +14,0 @@ - [PR #583](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/pull/583) - Fix typescript error CameraPreview.d.ts is not a module |
{ | ||
"name": "cordova-plugin-camera-preview", | ||
"version": "0.11.2", | ||
"version": "0.12.0", | ||
"description": "Cordova plugin that allows camera interaction from HTML code for showing camera preview below or on top of the HTML.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
199
README.md
@@ -9,3 +9,3 @@ # Cordova Plugin Camera Preview | ||
**PR's are greatly appreciated. Maintainer(s) wanted.** | ||
**PR's are greatly appreciated.** | ||
@@ -15,12 +15,14 @@ # Features | ||
<ul> | ||
<li>Start a camera preview from HTML code.</li> | ||
<li>Maintain HTML interactivity.</li> | ||
<li>Drag the preview box.</li> | ||
<li>Set camera color effect.</li> | ||
<li>Send the preview box to back of the HTML content.</li> | ||
<li>Set a custom position for the camera preview box.</li> | ||
<li>Set a custom size for the preview box.</li> | ||
<li>Set a custom alpha for the preview box.</li> | ||
<li>Start a camera preview from HTML code</li> | ||
<li>Take Photos and Snapshots</li> | ||
<li>Maintain HTML interactivity</li> | ||
<li>Drag the preview box</li> | ||
<li>Set camera color effect</li> | ||
<li>Send the preview box to back of the HTML content</li> | ||
<li>Set a custom position for the camera preview box</li> | ||
<li>Set a custom size for the preview box</li> | ||
<li>Set a custom alpha for the preview box</li> | ||
<li>Set the focus mode, zoom, color effects, exposure mode, white balance mode and exposure compensation</li> | ||
<li>Tap to focus</li> | ||
<li>Record Videos</li> | ||
</ul> | ||
@@ -57,3 +59,4 @@ | ||
#### iOS Quirks | ||
If you are developing for iOS 10+ you must also add the following to your config.xml | ||
1. It is not possible to use your computers webcam during testing in the simulator, you must device test. | ||
2. If you are developing for iOS 10+ you must also add the following to your config.xml | ||
@@ -72,10 +75,6 @@ ```xml | ||
#### Android Quirks (older devices) | ||
When using the plugin for older devices, the camera preview will take the focus inside the app once initialized. | ||
In order to prevent the app from closing when a user presses the back button, the event for the camera view is disabled. | ||
If you still want the user to navigate, you can add a listener for the back event for the preview | ||
(see <code>[onBackButton](#onBackButton)</code>) | ||
#### Android Quirks | ||
1. When using the plugin for older devices, the camera preview will take the focus inside the app once initialized. In order to prevent the app from closing when a user presses the back button, the event for the camera view is disabled. If you still want the user to navigate, you can add a listener for the back event for the preview (see <code>[onBackButton](#onBackButton)</code>) | ||
# Methods | ||
@@ -121,3 +120,3 @@ | ||
When setting the toBack to true, remember to add the style below on your app's HTML or body element: | ||
When setting `toBack` to true, remember to add the style below on your app's HTML or body element: | ||
@@ -130,4 +129,8 @@ ```css | ||
When both tapFocus and tapPhoto are true, the camera will focus, and take a picture as soon as the camera is done focusing. | ||
When both `tapFocus` and `tapPhoto` are true, the camera will focus, and take a picture as soon as the camera is done focusing. | ||
If you capture large images in Android you may notice that performace is poor, in those cases you can set `disableExifHeaderStripping` to true and instead just add some extra Javascript/HTML to get a proper display of your captured images without risking your application speed. | ||
When capturing large images you may want them to be stored into a file instead of having them base64 encoded, as enconding at least on Android is very expensive. With the feature `storeToFile` enabled the plugin will capture the image into a temporary file inside the application temporary cache (the same place where Cordova will extract your assets). This method is better used with `disableExifHeaderStripping` to get the best possible performance. | ||
### stopCamera([successCallback, errorCallback]) | ||
@@ -534,143 +537,32 @@ | ||
# storeToFile | ||
### startRecordVideo(options, cb, [errorCallback]) | ||
When capturing large images you may want them to be stored into a file instead of having them | ||
base64 enconded, as enconding at least on Android is very expensive. With the feature storeToFile enabled | ||
the plugin will capture the image into a temporary file inside the application temporary cache (the same | ||
place where Cordova will extract your assets). This method is better used with *disableExifHeaderStripping* | ||
to get the best possible performance. | ||
*Currently this feature is for Android only. A PR for iOS support would be happily accepted* | ||
<info>Start recording video to the cache.</info><br/> | ||
Example: | ||
```html | ||
<script src="https://raw.githubusercontent.com/blueimp/JavaScript-Load-Image/master/js/load-image.all.min.js"></script> | ||
<p><div id="originalPicture" style="width: 100%"></div></p> | ||
``` | ||
```javascript | ||
let options = { | ||
x: 0, | ||
y: 0, | ||
width: window.screen.width, | ||
height: window.screen.height, | ||
camera: CameraPreview.CAMERA_DIRECTION.BACK, | ||
toBack: false, | ||
tapPhoto: true, | ||
tapFocus: false, | ||
previewDrag: false, | ||
disableExifHeaderStripping: true, | ||
storeToFile: true | ||
}; | ||
.... | ||
function gotRotatedCanvas(canvasimg) { | ||
var displayCanvas = $('canvas#display-canvas'); | ||
loadImage.scale(canvasimg, function(img){ | ||
displayCanvas.drawImage(img) | ||
}, { | ||
maxWidth: displayCanvas.width, | ||
maxHeight: displayCanvas.height | ||
}); | ||
var opt = { | ||
cameraDirection: CameraPreview.CAMERA_DIRECTION.BACK, | ||
width: (window.screen.width / 2), | ||
height: (window.screen.height / 2), | ||
quality: 60, | ||
withFlash: false | ||
} | ||
CameraPreview.getSupportedPictureSizes(function(dimensions){ | ||
dimensions.sort(function(a, b){ | ||
return (b.width * b.height - a.width * a.height); | ||
}); | ||
var dimension = dimensions[0]; | ||
CameraPreview.takePicture({width:dimension.width, height:dimension.height, quality: 85}, function(path){ | ||
var image = 'file://' + path; | ||
let holder = document.getElementById('originalPicture'); | ||
let width = holder.offsetWidth; | ||
loadImage( | ||
image, | ||
function(canvas) { | ||
holder.innerHTML = ""; | ||
if (app.camera === 'front') { | ||
// front camera requires we flip horizontally | ||
canvas.style.transform = 'scale(1, -1)'; | ||
} | ||
holder.appendChild(canvas); | ||
}, | ||
{ | ||
maxWidth: width, | ||
orientation: true, | ||
canvas: true | ||
} | ||
); | ||
}); | ||
CameraPreview.startRecordVideo(opts, function(filePath){ | ||
console.log(filePath) | ||
}); | ||
``` | ||
## disableExifHeaderStripping | ||
### stopRecordVideo(cb, [errorCallback]) | ||
If you want to capture large images you will notice in Android that performace is very bad, in those cases you can set | ||
this flag, and add some extra Javascript/HTML to get a proper display of your captured images without risking your application speed. | ||
*Currently this feature is for Android only. A PR for iOS support would be happily accepted* | ||
Example: | ||
<info>Stop recording video and return video file path</info><br/> | ||
```html | ||
<script src="https://raw.githubusercontent.com/blueimp/JavaScript-Load-Image/master/js/load-image.all.min.js"></script> | ||
<p><div id="originalPicture" style="width: 100%"></div></p> | ||
``` | ||
```javascript | ||
let options = { | ||
x: 0, | ||
y: 0, | ||
width: window.screen.width, | ||
height: window.screen.height, | ||
camera: CameraPreview.CAMERA_DIRECTION.BACK, | ||
toBack: false, | ||
tapPhoto: true, | ||
tapFocus: false, | ||
previewDrag: false, | ||
disableExifHeaderStripping: true | ||
}; | ||
.... | ||
function gotRotatedCanvas(canvasimg) { | ||
var displayCanvas = $('canvas#display-canvas'); | ||
loadImage.scale(canvasimg, function(img){ | ||
displayCanvas.drawImage(img) | ||
}, { | ||
maxWidth: displayCanvas.width, | ||
maxHeight: displayCanvas.height | ||
}); | ||
} | ||
CameraPreview.getSupportedPictureSizes(function(dimensions){ | ||
dimensions.sort(function(a, b){ | ||
return (b.width * b.height - a.width * a.height); | ||
}); | ||
var dimension = dimensions[0]; | ||
CameraPreview.takePicture({width:dimension.width, height:dimension.height, quality: 85}, function(base64PictureData){ | ||
/* | ||
base64PictureData is base64 encoded jpeg image. Use this data to store to a file or upload. | ||
Its up to the you to figure out the best way to save it to disk or whatever for your application. | ||
*/ | ||
var image = 'data:image/jpeg;base64,' + imgData; | ||
let holder = document.getElementById('originalPicture'); | ||
let width = holder.offsetWidth; | ||
loadImage( | ||
image, | ||
function(canvas) { | ||
holder.innerHTML = ""; | ||
if (app.camera === 'front') { | ||
// front camera requires we flip horizontally | ||
canvas.style.transform = 'scale(1, -1)'; | ||
} | ||
holder.appendChild(canvas); | ||
}, | ||
{ | ||
maxWidth: width, | ||
orientation: true, | ||
canvas: true | ||
} | ||
); | ||
}); | ||
CameraPreview.stopRecordVideo(function(filePath) { | ||
console.log(filePath); | ||
}); | ||
``` | ||
@@ -774,17 +666,2 @@ | ||
# IOS Quirks | ||
It is not possible to use your computers webcam during testing in the simulator, you must device test. | ||
# Customize Android Support Library versions (Android only) | ||
The default `ANDROID_SUPPORT_LIBRARY_VERSION` is set to `26+`. | ||
If you need a different version, add argument `--variable ANDROID_SUPPORT_LIBRARY_VERSION="{version}"`. | ||
Or edit `config.xml` with following, | ||
```xml | ||
<plugin name="cordova-plugin-camera-preview" spec="X.X.X"> | ||
<variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="26+" /> | ||
</plugin> | ||
``` | ||
# Sample App | ||
@@ -791,0 +668,0 @@ |
@@ -13,67 +13,69 @@ declare module 'cordova-plugin-camera-preview' { | ||
interface CameraPreviewStartCameraOptions { | ||
alpha?: number; | ||
camera?: CameraPreviewCameraDirection|string; | ||
height?: number; | ||
previewDrag?: boolean; | ||
tapFocus?: boolean; | ||
tapPhoto?: boolean; | ||
toBack?: boolean; | ||
width?: number; | ||
x?: number; | ||
y?: number; | ||
disableExifHeaderStripping?: boolean; | ||
storeToFile?: boolean; | ||
alpha?: number; | ||
camera?: CameraPreviewCameraDirection|string; | ||
height?: number; | ||
previewDrag?: boolean; | ||
tapFocus?: boolean; | ||
tapPhoto?: boolean; | ||
toBack?: boolean; | ||
width?: number; | ||
x?: number; | ||
y?: number; | ||
disableExifHeaderStripping?: boolean; | ||
storeToFile?: boolean; | ||
} | ||
interface CameraPreviewTakePictureOptions { | ||
height?: number; | ||
quality?: number; | ||
width?: number; | ||
height?: number; | ||
quality?: number; | ||
width?: number; | ||
} | ||
interface CameraPreviewTakeSnapshotOptions { | ||
quality?: number; | ||
quality?: number; | ||
} | ||
interface CameraPreviewPreviewSizeDimension { | ||
height?: number; | ||
width?: number; | ||
height?: number; | ||
width?: number; | ||
} | ||
interface CameraPreview { | ||
startCamera(options?: CameraPreviewStartCameraOptions, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
stopCamera(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
switchCamera(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
hide(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
show(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
takePicture(options?: CameraPreviewTakePictureOptions|CameraPreviewSuccessHandler, onSuccess?: CameraPreviewSuccessHandler|CameraPreviewErrorHandler, onError?: CameraPreviewErrorHandler): void; | ||
takeSnapshot(options?: CameraPreviewTakeSnapshotOptions|CameraPreviewSuccessHandler, onSuccess?: CameraPreviewSuccessHandler|CameraPreviewErrorHandler, onError?: CameraPreviewErrorHandler): void; | ||
setColorEffect(effect: CameraPreviewColorEffect|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setZoom(zoom?: number, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getMaxZoom(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedFocusMode(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getZoom(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getHorizontalFOV(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setPreviewSize(dimensions?: CameraPreviewPreviewSizeDimension|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedPictureSizes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedFlashModes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedColorEffects(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setFlashMode(flashMode: CameraPreviewFlashMode|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedFocusModes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getFocusMode(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setFocusMode(focusMode?: CameraPreviewFocusMode|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
tapToFocus(xPoint?: number, yPoint?: number, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getExposureModes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getExposureMode(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setExposureMode(exposureMode?: CameraPreviewExposureMode, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getExposureCompensation(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setExposureCompensation(exposureCompensation?: number, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getExposureCompensationRange(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedWhiteBalanceModes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedWhiteBalanceMode(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setWhiteBalanceMode(whiteBalanceMode?: CameraPreviewWhiteBalanceMode|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
onBackButton(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getBlob(path: string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getCameraCharacteristics(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
startCamera(options?: CameraPreviewStartCameraOptions, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
stopCamera(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
switchCamera(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
hide(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
show(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
takePicture(options?: CameraPreviewTakePictureOptions|CameraPreviewSuccessHandler, onSuccess?: CameraPreviewSuccessHandler|CameraPreviewErrorHandler, onError?: CameraPreviewErrorHandler): void; | ||
takeSnapshot(options?: CameraPreviewTakeSnapshotOptions|CameraPreviewSuccessHandler, onSuccess?: CameraPreviewSuccessHandler|CameraPreviewErrorHandler, onError?: CameraPreviewErrorHandler): void; | ||
setColorEffect(effect: CameraPreviewColorEffect|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setZoom(zoom?: number, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
startRecordVideo(options?:any|CameraPreviewSuccessHandler, onSuccess?:CameraPreviewSuccessHandler|CameraPreviewErrorHandler, onError?:CameraPreviewErrorHandler):void; | ||
stopRecordVideo(CameraPreviewSuccessHandler, onSuccess?:CameraPreviewSuccessHandler|CameraPreviewErrorHandler, onError?:CameraPreviewErrorHandler):void; | ||
getMaxZoom(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedFocusMode(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getZoom(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getHorizontalFOV(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setPreviewSize(dimensions?: CameraPreviewPreviewSizeDimension|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedPictureSizes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedFlashModes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedColorEffects(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setFlashMode(flashMode: CameraPreviewFlashMode|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedFocusModes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getFocusMode(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setFocusMode(focusMode?: CameraPreviewFocusMode|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
tapToFocus(xPoint?: number, yPoint?: number, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getExposureModes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getExposureMode(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setExposureMode(exposureMode?: CameraPreviewExposureMode, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getExposureCompensation(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setExposureCompensation(exposureCompensation?: number, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getExposureCompensationRange(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedWhiteBalanceModes(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getSupportedWhiteBalanceMode(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
setWhiteBalanceMode(whiteBalanceMode?: CameraPreviewWhiteBalanceMode|string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
onBackButton(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getBlob(path: string, onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
getCameraCharacteristics(onSuccess?: CameraPreviewSuccessHandler, onError?: CameraPreviewErrorHandler): void; | ||
} | ||
} |
@@ -10,281 +10,328 @@ var argscheck = require('cordova/argscheck'), | ||
function isFunction(obj) { | ||
return !!(obj && obj.constructor && obj.call && obj.apply); | ||
return !!(obj && obj.constructor && obj.call && obj.apply); | ||
}; | ||
CameraPreview.startCamera = function(options, onSuccess, onError) { | ||
if(!options){ | ||
options = {}; | ||
}else if(isFunction(options)){ | ||
onSuccess = options; | ||
options = {}; | ||
} | ||
options.x = options.x || 0; | ||
options.y = options.y || 0; | ||
options.width = options.width || window.screen.width; | ||
options.height = options.height || window.screen.height; | ||
options.camera = options.camera || CameraPreview.CAMERA_DIRECTION.FRONT; | ||
if (typeof(options.tapPhoto) === 'undefined') { | ||
options.tapPhoto = true; | ||
} | ||
if (!options) { | ||
options = {}; | ||
} else if (isFunction(options)) { | ||
onSuccess = options; | ||
options = {}; | ||
} | ||
if (typeof (options.tapFocus) == 'undefined') { | ||
options.tapFocus = false; | ||
} | ||
options.x = options.x || 0; | ||
options.y = options.y || 0; | ||
options.previewDrag = options.previewDrag || false; | ||
options.toBack = options.toBack || false; | ||
if (typeof(options.alpha) === 'undefined') { | ||
options.alpha = 1; | ||
} | ||
options.disableExifHeaderStripping = options.disableExifHeaderStripping || false; | ||
options.storeToFile = options.storeToFile || false; | ||
exec(onSuccess, onError, PLUGIN_NAME, "startCamera", [options.x, options.y, options.width, options.height, options.camera, options.tapPhoto, options.previewDrag, options.toBack, options.alpha, options.tapFocus, options.disableExifHeaderStripping, options.storeToFile]); | ||
options.width = options.width || window.screen.width; | ||
options.height = options.height || window.screen.height; | ||
options.camera = options.camera || CameraPreview.CAMERA_DIRECTION.FRONT; | ||
if (typeof(options.tapPhoto) === 'undefined') { | ||
options.tapPhoto = true; | ||
} | ||
if (typeof (options.tapFocus) == 'undefined') { | ||
options.tapFocus = false; | ||
} | ||
options.previewDrag = options.previewDrag || false; | ||
options.toBack = options.toBack || false; | ||
if (typeof(options.alpha) === 'undefined') { | ||
options.alpha = 1; | ||
} | ||
options.disableExifHeaderStripping = options.disableExifHeaderStripping || false; | ||
options.storeToFile = options.storeToFile || false; | ||
exec(onSuccess, onError, PLUGIN_NAME, "startCamera", [ | ||
options.x, | ||
options.y, | ||
options.width, | ||
options.height, | ||
options.camera, | ||
options.tapPhoto, | ||
options.previewDrag, | ||
options.toBack, | ||
options.alpha, | ||
options.tapFocus, | ||
options.disableExifHeaderStripping, | ||
options.storeToFile | ||
]); | ||
}; | ||
CameraPreview.stopCamera = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "stopCamera", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "stopCamera", []); | ||
}; | ||
CameraPreview.switchCamera = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "switchCamera", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "switchCamera", []); | ||
}; | ||
CameraPreview.hide = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "hideCamera", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "hideCamera", []); | ||
}; | ||
CameraPreview.show = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "showCamera", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "showCamera", []); | ||
}; | ||
CameraPreview.takeSnapshot = function(opts, onSuccess, onError) { | ||
if (!opts) { | ||
opts = {}; | ||
} else if (isFunction(opts)) { | ||
onSuccess = opts; | ||
opts = {}; | ||
} | ||
if (!opts) { | ||
opts = {}; | ||
} else if (isFunction(opts)) { | ||
onSuccess = opts; | ||
opts = {}; | ||
} | ||
if (!isFunction(onSuccess)) { | ||
return false; | ||
} | ||
if (!isFunction(onSuccess)) { | ||
return false; | ||
} | ||
if (!opts.quality || opts.quality > 100 || opts.quality < 0) { | ||
opts.quality = 85; | ||
} | ||
if (!opts.quality || opts.quality > 100 || opts.quality < 0) { | ||
opts.quality = 85; | ||
} | ||
exec(onSuccess, onError, PLUGIN_NAME, "takeSnapshot", [opts.quality]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "takeSnapshot", [opts.quality]); | ||
}; | ||
CameraPreview.takePicture = function(opts, onSuccess, onError) { | ||
if (!opts) { | ||
opts = {}; | ||
} else if (isFunction(opts)) { | ||
onSuccess = opts; | ||
opts = {}; | ||
} | ||
if (!opts) { | ||
opts = {}; | ||
} else if (isFunction(opts)) { | ||
onSuccess = opts; | ||
opts = {}; | ||
} | ||
if (!isFunction(onSuccess)) { | ||
return false; | ||
} | ||
if (!isFunction(onSuccess)) { | ||
return false; | ||
} | ||
opts.width = opts.width || 0; | ||
opts.height = opts.height || 0; | ||
opts.width = opts.width || 0; | ||
opts.height = opts.height || 0; | ||
if (!opts.quality || opts.quality > 100 || opts.quality < 0) { | ||
opts.quality = 85; | ||
} | ||
if (!opts.quality || opts.quality > 100 || opts.quality < 0) { | ||
opts.quality = 85; | ||
} | ||
exec(onSuccess, onError, PLUGIN_NAME, "takePicture", [opts.width, opts.height, opts.quality]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "takePicture", [opts.width, opts.height, opts.quality]); | ||
}; | ||
CameraPreview.setColorEffect = function(effect, onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "setColorEffect", [effect]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "setColorEffect", [effect]); | ||
}; | ||
CameraPreview.setZoom = function(zoom, onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "setZoom", [zoom]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "setZoom", [zoom]); | ||
}; | ||
CameraPreview.getMaxZoom = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getMaxZoom", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getMaxZoom", []); | ||
}; | ||
CameraPreview.getZoom = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getZoom", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getZoom", []); | ||
}; | ||
CameraPreview.getHorizontalFOV = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getHorizontalFOV", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getHorizontalFOV", []); | ||
}; | ||
CameraPreview.setPreviewSize = function(dimensions, onSuccess, onError) { | ||
dimensions = dimensions || {}; | ||
dimensions.width = dimensions.width || window.screen.width; | ||
dimensions.height = dimensions.height || window.screen.height; | ||
dimensions = dimensions || {}; | ||
dimensions.width = dimensions.width || window.screen.width; | ||
dimensions.height = dimensions.height || window.screen.height; | ||
exec(onSuccess, onError, PLUGIN_NAME, "setPreviewSize", [dimensions.width, dimensions.height]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "setPreviewSize", [dimensions.width, dimensions.height]); | ||
}; | ||
CameraPreview.getSupportedPictureSizes = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedPictureSizes", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedPictureSizes", []); | ||
}; | ||
CameraPreview.getSupportedFlashModes = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedFlashModes", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedFlashModes", []); | ||
}; | ||
CameraPreview.getSupportedColorEffects = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedColorEffects", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedColorEffects", []); | ||
}; | ||
CameraPreview.setFlashMode = function(flashMode, onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "setFlashMode", [flashMode]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "setFlashMode", [flashMode]); | ||
}; | ||
CameraPreview.getFlashMode = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getFlashMode", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getFlashMode", []); | ||
}; | ||
CameraPreview.getSupportedFocusModes = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedFocusModes", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedFocusModes", []); | ||
}; | ||
CameraPreview.getFocusMode = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getFocusMode", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getFocusMode", []); | ||
}; | ||
CameraPreview.setFocusMode = function(focusMode, onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "setFocusMode", [focusMode]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "setFocusMode", [focusMode]); | ||
}; | ||
CameraPreview.tapToFocus = function(xPoint, yPoint, onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "tapToFocus", [xPoint, yPoint]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "tapToFocus", [xPoint, yPoint]); | ||
}; | ||
CameraPreview.getExposureModes = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getExposureModes", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getExposureModes", []); | ||
}; | ||
CameraPreview.getExposureMode = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getExposureMode", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getExposureMode", []); | ||
}; | ||
CameraPreview.setExposureMode = function(exposureMode, onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "setExposureMode", [exposureMode]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "setExposureMode", [exposureMode]); | ||
}; | ||
CameraPreview.getExposureCompensation = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getExposureCompensation", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getExposureCompensation", []); | ||
}; | ||
CameraPreview.setExposureCompensation = function(exposureCompensation, onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "setExposureCompensation", [exposureCompensation]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "setExposureCompensation", [exposureCompensation]); | ||
}; | ||
CameraPreview.getExposureCompensationRange = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getExposureCompensationRange", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getExposureCompensationRange", []); | ||
}; | ||
CameraPreview.getSupportedWhiteBalanceModes = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedWhiteBalanceModes", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getSupportedWhiteBalanceModes", []); | ||
}; | ||
CameraPreview.getWhiteBalanceMode = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getWhiteBalanceMode", []); | ||
exec(onSuccess, onError, PLUGIN_NAME, "getWhiteBalanceMode", []); | ||
}; | ||
CameraPreview.setWhiteBalanceMode = function(whiteBalanceMode, onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "setWhiteBalanceMode", [whiteBalanceMode]); | ||
exec(onSuccess, onError, PLUGIN_NAME, "setWhiteBalanceMode", [whiteBalanceMode]); | ||
}; | ||
CameraPreview.getCameraCharacteristics = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getCameraCharacteristics", []); | ||
}; | ||
CameraPreview.onBackButton = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "onBackButton"); | ||
exec(onSuccess, onError, PLUGIN_NAME, "onBackButton"); | ||
}; | ||
CameraPreview.getBlob = function(url, onSuccess, onError) { | ||
var xhr = new XMLHttpRequest | ||
xhr.onload = function() { | ||
if (xhr.status != 0 && (xhr.status < 200 || xhr.status >= 300)) { | ||
if (isFunction(onError)) { | ||
onError('Local request failed'); | ||
} | ||
return; | ||
} | ||
var blob = new Blob([xhr.response], {type: "image/jpeg"}); | ||
if (isFunction(onSuccess)) { | ||
onSuccess(blob); | ||
} | ||
}; | ||
xhr.onerror = function() { | ||
if (isFunction(onError)) { | ||
onError('Local request failed'); | ||
} | ||
}; | ||
xhr.open('GET', url); | ||
xhr.responseType = 'arraybuffer'; | ||
xhr.send(null); | ||
CameraPreview.getBlob = function (url, onSuccess, onError) { | ||
var xhr = new XMLHttpRequest | ||
xhr.onload = function() { | ||
if (xhr.status != 0 && (xhr.status < 200 || xhr.status >= 300)) { | ||
if (isFunction(onError)) { | ||
onError('Local request failed'); | ||
} | ||
return; | ||
} | ||
var blob = new Blob([xhr.response], {type: "image/jpeg"}); | ||
if (isFunction(onSuccess)) { | ||
onSuccess(blob); | ||
} | ||
}; | ||
xhr.onerror = function() { | ||
if (isFunction(onError)) { | ||
onError('Local request failed'); | ||
} | ||
}; | ||
xhr.open('GET', url); | ||
xhr.responseType = 'arraybuffer'; | ||
xhr.send(null); | ||
}; | ||
CameraPreview.getCameraCharacteristics = function(onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "getCameraCharacteristics", []); | ||
CameraPreview.startRecordVideo = function (opts, onSuccess, onError) { | ||
if (!opts) { | ||
opts = {}; | ||
} else if (isFunction(opts)) { | ||
onSuccess = opts; | ||
opts = {}; | ||
} | ||
if (!isFunction(onSuccess)) { | ||
return false; | ||
} | ||
opts.width = opts.width || 0; | ||
opts.height = opts.height || 0; | ||
if (!opts.quality || opts.quality > 100 || opts.quality < 0) { | ||
opts.quality = 85; | ||
} | ||
exec(onSuccess, onError, PLUGIN_NAME, "startRecordVideo", [opts.cameraDirection, opts.width, opts.height, opts.quality, opts.withFlash]); | ||
}; | ||
CameraPreview.stopRecordVideo = function (onSuccess, onError) { | ||
exec(onSuccess, onError, PLUGIN_NAME, "stopRecordVideo"); | ||
}; | ||
CameraPreview.FOCUS_MODE = { | ||
FIXED: 'fixed', | ||
AUTO: 'auto', | ||
CONTINUOUS: 'continuous', // IOS Only | ||
CONTINUOUS_PICTURE: 'continuous-picture', // Android Only | ||
CONTINUOUS_VIDEO: 'continuous-video', // Android Only | ||
EDOF: 'edof', // Android Only | ||
INFINITY: 'infinity', // Android Only | ||
MACRO: 'macro' // Android Only | ||
FIXED: 'fixed', | ||
AUTO: 'auto', | ||
CONTINUOUS: 'continuous', // IOS Only | ||
CONTINUOUS_PICTURE: 'continuous-picture', // Android Only | ||
CONTINUOUS_VIDEO: 'continuous-video', // Android Only | ||
EDOF: 'edof', // Android Only | ||
INFINITY: 'infinity', // Android Only | ||
MACRO: 'macro' // Android Only | ||
}; | ||
CameraPreview.EXPOSURE_MODE = { | ||
LOCK: 'lock', | ||
AUTO: 'auto', // IOS Only | ||
CONTINUOUS: 'continuous', // IOS Only | ||
CUSTOM: 'custom' // IOS Only | ||
LOCK: 'lock', | ||
AUTO: 'auto', // IOS Only | ||
CONTINUOUS: 'continuous', // IOS Only | ||
CUSTOM: 'custom' // IOS Only | ||
}; | ||
CameraPreview.WHITE_BALANCE_MODE = { | ||
LOCK: 'lock', | ||
AUTO: 'auto', | ||
CONTINUOUS: 'continuous', | ||
INCANDESCENT: 'incandescent', | ||
CLOUDY_DAYLIGHT: 'cloudy-daylight', | ||
DAYLIGHT: 'daylight', | ||
FLUORESCENT: 'fluorescent', | ||
SHADE: 'shade', | ||
TWILIGHT: 'twilight', | ||
WARM_FLUORESCENT: 'warm-fluorescent' | ||
LOCK: 'lock', | ||
AUTO: 'auto', | ||
CONTINUOUS: 'continuous', | ||
INCANDESCENT: 'incandescent', | ||
CLOUDY_DAYLIGHT: 'cloudy-daylight', | ||
DAYLIGHT: 'daylight', | ||
FLUORESCENT: 'fluorescent', | ||
SHADE: 'shade', | ||
TWILIGHT: 'twilight', | ||
WARM_FLUORESCENT: 'warm-fluorescent' | ||
}; | ||
CameraPreview.FLASH_MODE = { | ||
OFF: 'off', | ||
ON: 'on', | ||
AUTO: 'auto', | ||
RED_EYE: 'red-eye', // Android Only | ||
TORCH: 'torch' | ||
OFF: 'off', | ||
ON: 'on', | ||
AUTO: 'auto', | ||
RED_EYE: 'red-eye', // Android Only | ||
TORCH: 'torch' | ||
}; | ||
CameraPreview.COLOR_EFFECT = { | ||
AQUA: 'aqua', // Android Only | ||
BLACKBOARD: 'blackboard', // Android Only | ||
MONO: 'mono', | ||
NEGATIVE: 'negative', | ||
NONE: 'none', | ||
POSTERIZE: 'posterize', | ||
SEPIA: 'sepia', | ||
SOLARIZE: 'solarize', // Android Only | ||
WHITEBOARD: 'whiteboard' // Android Only | ||
AQUA: 'aqua', // Android Only | ||
BLACKBOARD: 'blackboard', // Android Only | ||
MONO: 'mono', | ||
NEGATIVE: 'negative', | ||
NONE: 'none', | ||
POSTERIZE: 'posterize', | ||
SEPIA: 'sepia', | ||
SOLARIZE: 'solarize', // Android Only | ||
WHITEBOARD: 'whiteboard' // Android Only | ||
}; | ||
CameraPreview.CAMERA_DIRECTION = { | ||
BACK: 'back', | ||
FRONT: 'front' | ||
BACK: 'back', | ||
FRONT: 'front' | ||
}; | ||
module.exports = CameraPreview; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
348087
341
672