cordova-plugin-camera-preview
cordova-plugin-camera-preview copied to clipboard
Cordova plugin that allow camera interaction from HTML code
Cordova CameraPreview Plugin
Cordova plugin that allows camera interaction from HTML code.
Show camera preview popup on top of the HTML.
Features:
- Start a camera preview from HTML code.
- Drag the preview box.
- Set camera color effect.
- Send the preview box to back of the HTML content.
- Set a custom position for the camera preview box.
- Set a custom size for the preview box.
- Set a custom alpha for the preview box.
- Maintain HTML interactivity.
Installation:
cordova plugin add cordova-plugin-camera-preview
ionic plugin add cordova-plugin-camera-preview
Phonegap Build:
<gap:plugin name="cordova-plugin-camera-preview" />
Methods:
startCamera(options, successCallback, errorCallback)
When setting the toBack to TRUE, remember to add the style below on your app's HTML or body element:
html, body {
background-color: transparent;
}
Javascript:
/* All options stated are optional and will default to values here */
CameraPreview.startCamera({x: 0, y: 0, width: window.device.width, height: window.device.height, camera: "front", tapPhoto: true, previewDrag: false, toBack: false});
stopCamera(successCallback, errorCallback)
CameraPreview.stopCamera();
takePicture(size, successCallback, errorCallback)
CameraPreview.takePicture({maxWidth:640, maxHeight:640});
setOnPictureTakenHandler(successCallback, errorCallback)
CameraPreview.setOnPictureTakenHandler(function(picture) {
document.getElementById('picture').src = picture; // base64 picture;
});
switchCamera(successCallback, errorCallback)
CameraPreview.switchCamera();
show(successCallback, errorCallback)
CameraPreview.show();
hide(successCallback, errorCallback)
CameraPreview.hide();
setFlashMode(flashMode, successCallback, errorCallback)
OFF
, ON
, AUTO
CameraPreview.setFlashMode('ON');
setColorEffect(colorEffect, successCallback, errorCallback)
iOS Effects: none
, mono
, negative
, posterize
, sepia
.
Android Effects: none
, mono
, negative
, posterize
, sepia
, aqua
, blackboard
, solarize
, whiteboard
CameraPreview.setColorEffect('sepia');
setOnLogHandler(successCallback, errorCallback)
CameraPreview.setOnLogHandler(function(){
console.log('log handler set!');
});
IOS Quirks:
It is not possible to use your computers webcam during testing in the simulator, you must device test.
Sample:
Cordova: cordova-plugin-camera-preview-sample-app for a complete working Cordova example for Android and iOS platforms.
Ionic: cordova-plugin-camera-preview-ionic-sample-app for a complete working Ionic example for Android and iOS platforms.
Android Screenshots: