Preview Camera Plugin for iOS, Android
npm install @numbersprotocol/preview-camera
npx cap syncecho(...)startPreview()stopPreview()takePhoto()capturePhoto()startRecord()stopRecord()flipCamera()getFlashModes()setFlashMode()isTorchOn()enableTorch(...)isTorchAvailable()focus(...)minAvailableZoom()maxAvailableZoom()zoom(...)setQuality(...)saveFileToUserDevice(...)checkPermissions()requestPermissions()addListener('captureSuccessResult', ...)addListener('captureErrorResult', ...)addListener('captureVideoFinished', ...)addListener('capturePhotoFinished', ...)addListener('accelerometerOrientation', ...)removeAllListeners()- Interfaces
- Type Aliases
echo(options: { value: string; }) => Promise<{ value: string; }>| Param | Type |
|---|---|
options |
{ value: string; } |
Returns: Promise<{ value: string; }>
startPreview() => Promise<void>stopPreview() => Promise<void>takePhoto() => Promise<void>capturePhoto() => Promise<void>startRecord() => Promise<void>stopRecord() => Promise<void>flipCamera() => Promise<void>getFlashModes() => Promise<any>Returns: Promise<any>
setFlashMode() => Promise<void>isTorchOn() => Promise<{ result: boolean; }>Returns: Promise<{ result: boolean; }>
enableTorch(options: { enable: boolean; }) => Promise<void>| Param | Type |
|---|---|
options |
{ enable: boolean; } |
isTorchAvailable() => Promise<{ result: boolean; }>Returns: Promise<{ result: boolean; }>
focus(options: { x: number; y: number; }) => Promise<void>| Param | Type |
|---|---|
options |
{ x: number; y: number; } |
minAvailableZoom() => Promise<{ result: number; }>Returns: Promise<{ result: number; }>
maxAvailableZoom() => Promise<{ result: number; }>Returns: Promise<{ result: number; }>
zoom(options: { factor: number; }) => Promise<void>| Param | Type |
|---|---|
options |
{ factor: number; } |
setQuality(options: { quality: 'low' | 'hq'; }) => Promise<void>| Param | Type |
|---|---|
options |
{ quality: 'low' | 'hq'; } |
saveFileToUserDevice(options: { filePath: string; }) => Promise<void>| Param | Type |
|---|---|
options |
{ filePath: string; } |
checkPermissions() => Promise<PermissionStatus>Returns: Promise<PermissionStatus>
requestPermissions() => Promise<PermissionStatus>Returns: Promise<PermissionStatus>
addListener(eventName: 'captureSuccessResult', listenerFunc: (data: CaptureSuccessResult) => void) => Promise<PluginListenerHandle>| Param | Type |
|---|---|
eventName |
'captureSuccessResult' |
listenerFunc |
(data: CaptureSuccessResult) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: 'captureErrorResult', listenerFunc: (data: CaptureErrorResult) => void) => Promise<PluginListenerHandle>| Param | Type |
|---|---|
eventName |
'captureErrorResult' |
listenerFunc |
(data: CaptureErrorResult) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: 'captureVideoFinished', listenerFunc: (data: CaptureResult) => void) => Promise<PluginListenerHandle>| Param | Type |
|---|---|
eventName |
'captureVideoFinished' |
listenerFunc |
(data: CaptureResult) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: 'capturePhotoFinished', listenerFunc: (data: CaptureResult) => void) => Promise<PluginListenerHandle>| Param | Type |
|---|---|
eventName |
'capturePhotoFinished' |
listenerFunc |
(data: CaptureResult) => void |
Returns: Promise<PluginListenerHandle>
addListener(eventName: 'accelerometerOrientation', listenerFunc: (data: { orientation: CustomOrientation; }) => void) => Promise<PluginListenerHandle>| Param | Type |
|---|---|
eventName |
'accelerometerOrientation' |
listenerFunc |
(data: { orientation: CustomOrientation; }) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners() => Promise<void>camerapermission allows to take photo and record video without audio.microphonepermission allows to record video with audio.
| Prop | Type |
|---|---|
camera |
PermissionState |
microphone |
PermissionState |
| Prop | Type |
|---|---|
remove |
() => Promise<void> |
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". |
Represents the result of a failed capture operation.
| Prop | Type | Description |
|---|---|---|
errorMessage |
string |
The error message describing the cause of the failure. |
| 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 |
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
'portraitUp' | 'portraitDown' | 'landscapeRight' | 'landscaperLeft'