Preview Camera Plugin for iOS, Android
npm install @numbersprotocol/preview-camera
npx cap sync
{ value: string; }
|
**Returns:** Promise<{ value: string; }>
--------------------
### startPreview()
```typescript
startPreview() => PromisePromise<any>
--------------------
### setFlashMode()
```typescript
setFlashMode() => PromisePromise<{ result: boolean; }>
--------------------
### enableTorch(...)
```typescript
enableTorch(options: { enable: boolean; }) => Promise{ enable: boolean; }
|
--------------------
### isTorchAvailable()
```typescript
isTorchAvailable() => Promise<{ result: boolean; }>
```
**Returns:** Promise<{ result: boolean; }>
--------------------
### focus(...)
```typescript
focus(options: { x: number; y: number; }) => Promise{ x: number; y: number; }
|
--------------------
### minAvailableZoom()
```typescript
minAvailableZoom() => Promise<{ result: number; }>
```
**Returns:** Promise<{ result: number; }>
--------------------
### maxAvailableZoom()
```typescript
maxAvailableZoom() => Promise<{ result: number; }>
```
**Returns:** Promise<{ result: number; }>
--------------------
### zoom(...)
```typescript
zoom(options: { factor: number; }) => Promise{ factor: number; }
|
--------------------
### setQuality(...)
```typescript
setQuality(options: { quality: 'low' | 'hq'; }) => Promise{ quality: 'low' \| 'hq'; }
|
--------------------
### saveFileToUserDevice(...)
```typescript
saveFileToUserDevice(options: { filePath: string; }) => Promise{ filePath: string; }
|
--------------------
### checkPermissions()
```typescript
checkPermissions() => PromisePromise<PermissionStatus>
--------------------
### requestPermissions()
```typescript
requestPermissions() => PromisePromise<PermissionStatus>
--------------------
### addListener('captureSuccessResult', ...)
```typescript
addListener(eventName: 'captureSuccessResult', listenerFunc: (data: CaptureSuccessResult) => void) => Promise'captureSuccessResult'
|
| **`listenerFunc`** | (data: CaptureSuccessResult) => void
|
**Returns:** Promise<PluginListenerHandle> & PluginListenerHandle
--------------------
### addListener('captureErrorResult', ...)
```typescript
addListener(eventName: 'captureErrorResult', listenerFunc: (data: CaptureErrorResult) => void) => Promise'captureErrorResult'
|
| **`listenerFunc`** | (data: CaptureErrorResult) => void
|
**Returns:** Promise<PluginListenerHandle> & PluginListenerHandle
--------------------
### addListener('captureVideoFinished', ...)
```typescript
addListener(eventName: 'captureVideoFinished', listenerFunc: (data: CaptureResult) => void) => Promise'captureVideoFinished'
|
| **`listenerFunc`** | (data: CaptureResult) => void
|
**Returns:** Promise<PluginListenerHandle> & PluginListenerHandle
--------------------
### addListener('capturePhotoFinished', ...)
```typescript
addListener(eventName: 'capturePhotoFinished', listenerFunc: (data: CaptureResult) => void) => Promise'capturePhotoFinished'
|
| **`listenerFunc`** | (data: CaptureResult) => void
|
**Returns:** Promise<PluginListenerHandle> & PluginListenerHandle
--------------------
### addListener('accelerometerOrientation', ...)
```typescript
addListener(eventName: 'accelerometerOrientation', listenerFunc: (data: { orientation: CustomOrientation; }) => void) => Promise'accelerometerOrientation'
|
| **`listenerFunc`** | (data: { orientation: CustomOrientation; }) => void
|
**Returns:** Promise<PluginListenerHandle> & PluginListenerHandle
--------------------
### removeAllListeners()
```typescript
removeAllListeners() => PromisePermissionState
|
| **`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'