Skip to content

Latest commit

 

History

History
86 lines (74 loc) · 2.96 KB

README.md

File metadata and controls

86 lines (74 loc) · 2.96 KB

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 (Android, iOS is not implemented yet).
  • Set a custom position for the camera preview box.
  • Set a custom size for the preview box.
  • Maintain HTML interactivity.

Installation:

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

Methods:

startCamera(rect, defaultCamera, tapEnabled, dragEnabled)
Starts the camera preview instance.
Usage:


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

stopCamera()
Stops the camera preview instance.
Usage:
cordova.plugins.camerapreview.stopCamera();

takePicture()
Take the picture
Usage:
cordova.plugins.camerapreview.takePicture();

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


  	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.
Usage:
cordova.plugins.camerapreview.switchCamera();

show()
Show the camera preview box.
Usage:
cordova.plugins.camerapreview.show();

hide()
Hide the camera preview box.
Usage:
cordova.plugins.camerapreview.hide();

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

Android Screenshots:

Forked from https://github.com/stephan-nordnes-eriksen/CordovaCameraPreview due to his change in file saving on Android Fixing issue with camera rotation on load