Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview
cordova plugin for a showing simple camera preview
https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview
Last synced: about 1 month ago
JSON representation
cordova plugin for a showing simple camera preview
- Host: GitHub
- URL: https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview
- Owner: spoonconsulting
- Created: 2018-08-17T07:50:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T10:34:40.000Z (2 months ago)
- Last Synced: 2024-10-29T12:30:02.333Z (2 months ago)
- Language: Objective-C
- Size: 10.6 MB
- Stars: 3
- Watchers: 6
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
Cordova Plugin Simple Camera Preview
====================Cordova plugin that allows simple camera preview and taking pictures from Javascript and HTML
# Installation
```
cordova plugin add https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview.gitionic cordova plugin add https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview.git
```
Make the webview html background color transparent.
```css
html, body, .ion-app, .ion-content {
background-color: transparent;
}
```### Android
Uses Google's CameraX API# Methods
### setOptions(options, successCallback, errorCallback)
Get the ratio for the camera preview instance (4:3, 16:9, ....).
```javascript
const params = {
targetSize: 1024,
}SimpleCameraPreview.setOptions(params, (ratio) => {
console.log(ratio);
});
```### enable(options, successCallback, errorCallback)
Starts the camera preview instance.
```javascript
const params = {
targetSize: 1024,
direction: 'back', // Camera direction (front or back). Default is back.
}SimpleCameraPreview.enable(params, () => {
console.log("Camera enabled");
});
```### disable(successCallback, errorCallback)
Stops the camera preview instance.
```javascript
SimpleCameraPreview.disable(params, () => {
console.log("Camera disabled");
});
```### capture(options, successCallback, errorCallback)
Take the picture
```javascript
let options = {
flash: true,
};SimpleCameraPreview.capture(options, (imagaeNativePath) => {
console.log(imagaeNativePath);
});
```### setSize(options, successCallback, errorCallback)
Set the camera frame size
```javascript
let size = {
x: 0,
y: 0,
width: 1080,
height: 1920,
};SimpleCameraPreview.setSize(size, () => {
console.log("Camera frame size set");
});
```### deviceHasUltraWideCamera(successCallback, errorCallback)
Check if device has ultra-wide camera
```javascript
SimpleCameraPreview.deviceHasUltraWideCamera(size, (value: boolean) => {
console.log("Device has ultra-wide camera?: ", value);
});
```### switchCameraTo(option, successCallback, errorCallback)
Switch camera between wide or auto
The variable lens can take two values:
```javascript
"wide"or
"auto"
``````javascript
const params = {
lens: "wide",
}SimpleCameraPreview.switchCameraTo(
params,
(value: unknown) => {
return (typeof value === "boolean" ? value : false);
},
(e: unknown) => {
console.log("cannot switch camera: ", e);
}
);
```