Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@spoonconsulting/cordova-plugin-simple-camera-preview

Package Overview
Dependencies
Maintainers
0
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spoonconsulting/cordova-plugin-simple-camera-preview

Cordova plugin that allows camera interaction from HTML code for showing camera preview below or on top of the HTML.

  • 2.0.31
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
120
increased by8.11%
Maintainers
0
Weekly downloads
 
Created
Source

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.git

ionic cordova plugin add https://github.com/spoonconsulting/cordova-plugin-simple-camera-preview.git

Make the webview html background color transparent.

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, ....).

const params = {
  targetSize: 1024,
}

SimpleCameraPreview.setOptions(params, (ratio) => {
  console.log(ratio);
});

enable(options, successCallback, errorCallback)

Starts the camera preview instance.

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.

SimpleCameraPreview.disable(params, () => {
  console.log("Camera disabled");
});

capture(options, successCallback, errorCallback)

Take the picture

let options = {
  flash: true,
};

SimpleCameraPreview.capture(options, (imagaeNativePath) => {
  console.log(imagaeNativePath);
});

setSize(options, successCallback, errorCallback)

Set the camera frame size

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


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:

  "wide"

  or

  "auto"


const params = {
  lens: "wide",
}

SimpleCameraPreview.switchCameraTo(
  params, 
  (value: unknown) => {
    return (typeof value === "boolean" ? value : false);
  },
  (e: unknown) => {
    console.log("cannot switch camera: ", e);
  }
);

Keywords

FAQs

Package last updated on 04 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc