1.0.6 • Published 8 years ago

cordova-camera-preview v1.0.6

Weekly downloads
23
License
-
Repository
-
Last release
8 years ago

Cordova CameraPreview Plugin

Cordova plugin that allows camera interaction from HTML code. Show camera preview popup on top of the HTML.

cordova plugin add https://github.com/mbppower/CordovaCameraPreview.git

Phonegap Build:

<gap:plugin name="com.mbppower.camerapreview" version="0.0.8" source="plugins.cordova.io" />

startCamera(rect, defaultCamera, tapEnabled, dragEnabled, toBack) Starts the camera preview instance. When setting the toBack to TRUE, remember to add the style bellow on your app's HTML body element:

style="background-color='transparent'"

Javascript:

var tapEnabled = true; //enable tap take picture
var dragEnabled = true; //enable preview box drag across the screen
var toBack = true; //send preview box to the back of the webview
var rect = {x: 100, y: 100, width: 200, height:200};
cordova.plugins.camerapreview.startCamera(rect, "front", tapEnabled, dragEnabled, toBack)

stopCamera() Stops the camera preview instance.

cordova.plugins.camerapreview.stopCamera();

takePicture(size) Take the picture, the parameter size is optional

cordova.plugins.camerapreview.takePicture({maxWidth:640, maxHeight:640});

setOnPictureTakenHandler(callback) Register a callback function that receives the original picture and the image captured from the preview box.

cordova.plugins.camerapreview.setOnPictureTakenHandler(function(result){
	document.getElementById('originalPicture').src = result[0];//originalPicturePath;
	document.getElementById('previewPicture').src = result[1];//previewPicturePath;
});

switchCamera() Switch from the rear camera and front camera, if available.

cordova.plugins.camerapreview.switchCamera();

show() Show the camera preview box.

cordova.plugins.camerapreview.show();

hide() Hide the camera preview box.

cordova.plugins.camerapreview.hide();

Base64 image: Use the cordova-file in order to read the picture file and them get the base64. Please, refer to this documentation: http://docs.phonegap.com/en/edge/cordova_file_file.md.html Method readAsDataURL: Read file and return data as a base64-encoded data URL.

Sample: Please see the CordovaCameraPreviewApp for a complete working example for Android and iOS platforms.

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago