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

nativescript-camera-plus-fixed-distorted

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-camera-plus-fixed-distorted

An advanced, embeddable camera for NativeScript.

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

NativeScript Camera Plus

A NativeScript camera with all the bells and whistles which can be embedded inside a view. This plugin was sponsored by LiveShopper

LiveShopper Logo

npm npm stars forks license

nStudio banner

Do you need assistance on your project or plugin? Contact the nStudio team anytime at team@nstudio.io to get up to speed with the best practices in mobile and web app development.


Installation

tns plugin add @nstudio/nativescript-camera-plus

Sample

Yes the camera is rotated because it's a webcam to an emulator and it's just the way life works

Camera Plus

Demo

The demo apps work best when run on a real device. You can launch them from the simulator/emulator however the camera does not work on iOS simulators. Android emulators will work with cameras if you enable your webcam.

Android Emulator Note

The camera in your webcam being used on emulators will likely be rotated sideways (incorrectly). The actual camera output will be correctly oriented, it's only the preview on emulators that present the preview incorrectly. This issue shouldn't be present on real devices due to the camera being oriented correctly on the device vs. a webcam in a computer.

NOTE: You may want to run: npm run nuke first to clear and reset directories.

Run Vanilla Demo

Plug device in, then:

npm run demo.ios.device
// or...
npm run demo.android.device

Run Angular Demo

Plug device in, then:

npm run demo.ng.ios.device
// or...
npm run demo.ng.android.device

Properties

NameTypeDescription
debugbooleanIf true logs will be output in the console to help debug the Camera Plus events.
confirmPhotosbooleanIf true the default take picture event will present a confirmation dialog before saving. Default is true.
confirmRetakeTextstringWhen confirming capture this text will be presented to the user to retake the photo. Default is 'Retake'
confirmSaveTextstringWhen confirming capture this text will be presented to the user to save the photo. Default is 'Save'
saveToGallerybooleanIf true the default take picture event will save to device gallery. Default is true.
galleryPickerModestringThe gallery/library selection mode. 'single' allows one image to be selected. 'multiple' allows multiple images. Default is 'multiple'
showFlashIconbooleanIf true the default flash toggle icon/button will show on the Camera Plus layout. Default is true.
showToggleIconbooleanIf true the default camera toggle (front/back) icon button will show on the Camera Plus layout. Default is true.
showCaptureIconbooleanIf true the default capture (take picture) icon/button will show on the Camera Plus layout. Default is true.
showGalleryIconbooleanIf true the choose from gallery/library icon/button will show on the Camera Plus layout. Default is true.
enableVideobooleanIf true the CameraPlus instance can record video and videos are shown in the gallery.

Static Properties

Note: These properties need set before the initialization of the camera. Users should set these in a component constructor before their view creates the component if the wish to change the default values. In case of enableVideo, this will be true if either the static property or the component property is true.

NameTypeDescription
enableVideobooleanVideo Support (off by default). Can reset it before using in different views if they want to go back/forth between photo/camera and video/camera
defaultCameraCameraTypesDefaults the camera correctly on launch. Default 'rear'. 'front' or 'rear'

Android Only Properties

NameTypeDescription
flashOnIconstringName of app_resource drawable for the native image button when flash is on (enabled).
flashOffIconstringName of app_resource drawable for the native image button when flash is off (disabled).
toggleCameraIconstringName of app_resource drawable for the toggle camera button.
takePicIconstringName of app_resource drawable for the take picture (capture) button.
galleryIconstringName of app_resource drawable for the open gallery (image library) button.
autoFocusbooleanIf true the camera will use continuous focus when the camera detects changes of the target.

iOS Only Properties

NameTypeDescription
doubleTapCameraSwitchbooleanEnable/disable double tap gesture to switch camera. (enabled)

Cross Platform Public Methods

MethodDescription
isCameraAvailable()Returns true if the device has at least one camera.
toggleFlash()Toggles the flash mode on the active camera.
toggleCamera()Toggles the active camera on the device.
chooseFromLibrary(opts?: IChooseOptions)Opens the device gallery (image library) for selecting images.
takePicture(opts?: ICaptureOptions)Takes a picture of the current preview in the CameraPlus.
getFlashMode(): stringAndroid: various strings possible: https://developer.android.com/reference/android/hardware/Camera.Parameters.html#getFlashMode() iOS: either 'on' or 'off'
record(opts?: IVideoOptions)Starts recording a video.
stop()Stops the video recording, when stopped the videoRecordingReadyEvent event will be emitted.

Android Only Public Methods

MethodDescription
requestCameraPermissions(explanationText?: string)Prompts the user to grant runtime permission to use the device camera. Returns a Promise.
hasCameraPermission()Returns true if the application has been granted access to the device camera.
requestStoragePermissions(explanationText?: string)Prompts the user to grant runtime permission to use external storage for saving and opening images from device gallery. Returns a Promise.
hasStoragePermissions()Returns true if the application has been granted access to the device storage.
getNumberOfCameras()Returns the number of cameras on the device.
hasFlash()Returns true if the active camera has a flash mode.

Events

NameDescription
errorEventExecutes when an error is emitted from CameraPlus
photoCapturedEventExecutes when a photo is taken.
toggleCameraEventExecutes when the device camera is toggled.
imagesSelectedEventExecutes when images are selected from the device library/gallery.
videoRecordingStartedEventExecutes when video starts recording.
videoRecordingFinishedEventExecutes when video stops recording but has not process yet.
videoRecordingReadyEventExecutes when video has completed processing and is ready to be used.
confirmScreenShownEventExecutes when the picture confirm dialog is shown..
confirmScreenDismissedEventExecutes when the picture confirm dialog is dismissed either by Retake or Save button.

Option Interfaces

export interface ICameraOptions {
  confirm?: boolean;
  saveToGallery?: boolean;
  keepAspectRatio?: boolean;
  height?: number;
  width?: number;
  autoSquareCrop?: boolean;
  confirmRetakeText?: string;
  confirmSaveText?: string;
}
export interface IChooseOptions {
  width?: number;
  height?: number;
  keepAspectRatio?: boolean;
  showImages?:  boolean;
  showVideos?: boolean;
}
export interface IVideoOptions {
  confirm?: boolean;
  saveToGallery?: boolean;
  height?: number;
  width?: number;
}

Keywords

FAQs

Package last updated on 28 Mar 2019

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