Skip to content

numbersprotocol/preview-camera

Repository files navigation

@numbersprotocol/preview-camera

Preview Camera Plugin for iOS, Android

Install

npm install @numbersprotocol/preview-camera
npx cap sync

API

echo(...)

echo(options: { value: string; }) => Promise<{ value: string; }>
Param Type
options { value: string; }

Returns: Promise<{ value: string; }>


startPreview()

startPreview() => Promise<void>

stopPreview()

stopPreview() => Promise<void>

takePhoto()

takePhoto() => Promise<void>

capturePhoto()

capturePhoto() => Promise<void>

startRecord()

startRecord() => Promise<void>

stopRecord()

stopRecord() => Promise<void>

flipCamera()

flipCamera() => Promise<void>

getFlashModes()

getFlashModes() => Promise<any>

Returns: Promise<any>


setFlashMode()

setFlashMode() => Promise<void>

isTorchOn()

isTorchOn() => Promise<{ result: boolean; }>

Returns: Promise<{ result: boolean; }>


enableTorch(...)

enableTorch(options: { enable: boolean; }) => Promise<void>
Param Type
options { enable: boolean; }

isTorchAvailable()

isTorchAvailable() => Promise<{ result: boolean; }>

Returns: Promise<{ result: boolean; }>


focus(...)

focus(options: { x: number; y: number; }) => Promise<void>
Param Type
options { x: number; y: number; }

minAvailableZoom()

minAvailableZoom() => Promise<{ result: number; }>

Returns: Promise<{ result: number; }>


maxAvailableZoom()

maxAvailableZoom() => Promise<{ result: number; }>

Returns: Promise<{ result: number; }>


zoom(...)

zoom(options: { factor: number; }) => Promise<void>
Param Type
options { factor: number; }

setQuality(...)

setQuality(options: { quality: 'low' | 'hq'; }) => Promise<void>
Param Type
options { quality: 'low' | 'hq'; }

saveFileToUserDevice(...)

saveFileToUserDevice(options: { filePath: string; }) => Promise<void>
Param Type
options { filePath: string; }

checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Returns: Promise<PermissionStatus>


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Returns: Promise<PermissionStatus>


addListener('captureSuccessResult', ...)

addListener(eventName: 'captureSuccessResult', listenerFunc: (data: CaptureSuccessResult) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'captureSuccessResult'
listenerFunc (data: CaptureSuccessResult) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('captureErrorResult', ...)

addListener(eventName: 'captureErrorResult', listenerFunc: (data: CaptureErrorResult) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'captureErrorResult'
listenerFunc (data: CaptureErrorResult) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('captureVideoFinished', ...)

addListener(eventName: 'captureVideoFinished', listenerFunc: (data: CaptureResult) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'captureVideoFinished'
listenerFunc (data: CaptureResult) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('capturePhotoFinished', ...)

addListener(eventName: 'capturePhotoFinished', listenerFunc: (data: CaptureResult) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'capturePhotoFinished'
listenerFunc (data: CaptureResult) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('accelerometerOrientation', ...)

addListener(eventName: 'accelerometerOrientation', listenerFunc: (data: { orientation: CustomOrientation; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'accelerometerOrientation'
listenerFunc (data: { orientation: CustomOrientation; }) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


removeAllListeners()

removeAllListeners() => Promise<void>

Interfaces

PermissionStatus

  • camera permission allows to take photo and record video without audio.
  • microphone permission allows to record video with audio.
Prop Type
camera PermissionState
microphone PermissionState

PluginListenerHandle

Prop Type
remove () => Promise<void>

CaptureSuccessResult

Represents the result of a successful capture operation.

Prop Type Description
mimeType 'image/jpeg' | 'video/mp4' The MIME type of the captured media. Examples: "image/jpeg", "video/mp4".
name string The name of the captured media file. Examples: "my-photo.jpg", "my-video.mp4".
path string The path to the captured media file. Example: "file://path-to-my-video.mp4".
size number The size of the captured media file in bytes. Example: "7046447".

CaptureErrorResult

Represents the result of a failed capture operation.

Prop Type Description
errorMessage string The error message describing the cause of the failure.

CaptureResult

Prop Type Description
filePath string File path for photo or video taken by camera. Example: file://your-app-dir/.../my-video.mp4
errorMessage string Error message if any

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

CustomOrientation

'portraitUp' | 'portraitDown' | 'landscapeRight' | 'landscaperLeft'