npm package: @scr2em/capacitor-plugin-recorder
Description: record audios and play them back
Author: me
Latest version: 0.0.8

# capacitor-plugin-recorder

ee

## Install

```bash
npm install capacitor-plugin-recorder
npx cap sync
```

## API

<docgen-index>

* [`requestPermission()`](#requestpermission)
* [`checkPermission()`](#checkpermission)
* [`startRecord(...)`](#startrecord)
* [`stopRecord(...)`](#stoprecord)
* [`pauseRecord(...)`](#pauserecord)
* [`resumeRecord(...)`](#resumerecord)
* [`preparePlay(...)`](#prepareplay)
* [`play(...)`](#play)
* [`pausePlay(...)`](#pauseplay)
* [`resumePlay(...)`](#resumeplay)
* [`stopPlay(...)`](#stopplay)
* [`seekTo(...)`](#seekto)
* [`getPlaybackStatus(...)`](#getplaybackstatus)
* [`getRecordingStatus(...)`](#getrecordingstatus)
* [`destroyRecorder(...)`](#destroyrecorder)
* [`destroyPlayer(...)`](#destroyplayer)
* [`addListener('recordingStatusChange', ...)`](#addlistenerrecordingstatuschange-)
* [`addListener('playbackStatusChange', ...)`](#addlistenerplaybackstatuschange-)
* [`removeAllListeners()`](#removealllisteners)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### requestPermission()

```typescript
requestPermission() => Promise<PermissionStatus>
```

Request microphone permission

**Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>

--------------------


### checkPermission()

```typescript
checkPermission() => Promise<PermissionStatus>
```

Check current permission status

**Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>

--------------------


### startRecord(...)

```typescript
startRecord(options?: StartRecordOptions | undefined) => Promise<StartRecordResult>
```

Start recording audio. Returns a recorderId that must be used for all subsequent operations on this recorder.

| Param         | Type                                                              |
| ------------- | ----------------------------------------------------------------- |
| **`options`** | <code><a href="#startrecordoptions">StartRecordOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#startrecordresult">StartRecordResult</a>&gt;</code>

--------------------


### stopRecord(...)

```typescript
stopRecord(options: RecorderOptions) => Promise<StopRecordResult>
```

Stop recording and return the recorded file path

| Param         | Type                                                        |
| ------------- | ----------------------------------------------------------- |
| **`options`** | <code><a href="#recorderoptions">RecorderOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#stoprecordresult">StopRecordResult</a>&gt;</code>

--------------------


### pauseRecord(...)

```typescript
pauseRecord(options: RecorderOptions) => Promise<void>
```

Pause the current recording

| Param         | Type                                                        |
| ------------- | ----------------------------------------------------------- |
| **`options`** | <code><a href="#recorderoptions">RecorderOptions</a></code> |

--------------------


### resumeRecord(...)

```typescript
resumeRecord(options: RecorderOptions) => Promise<void>
```

Resume a paused recording

| Param         | Type                                                        |
| ------------- | ----------------------------------------------------------- |
| **`options`** | <code><a href="#recorderoptions">RecorderOptions</a></code> |

--------------------


### preparePlay(...)

```typescript
preparePlay(options: PlayOptions) => Promise<PreparePlayResult>
```

Prepare an audio file for playback (loads metadata without playing).
Returns a playerId that must be used for all subsequent operations on this player.

| Param         | Type                                                |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#playoptions">PlayOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#prepareplayresult">PreparePlayResult</a>&gt;</code>

--------------------


### play(...)

```typescript
play(options: PlayerOptions) => Promise<void>
```

Start playing an audio file

| Param         | Type                                                    |
| ------------- | ------------------------------------------------------- |
| **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |

--------------------


### pausePlay(...)

```typescript
pausePlay(options: PlayerOptions) => Promise<void>
```

Pause audio playback

| Param         | Type                                                    |
| ------------- | ------------------------------------------------------- |
| **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |

--------------------


### resumePlay(...)

```typescript
resumePlay(options: PlayerOptions) => Promise<void>
```

Resume paused audio playback

| Param         | Type                                                    |
| ------------- | ------------------------------------------------------- |
| **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |

--------------------


### stopPlay(...)

```typescript
stopPlay(options: PlayerOptions) => Promise<void>
```

Stop audio playback

| Param         | Type                                                    |
| ------------- | ------------------------------------------------------- |
| **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |

--------------------


### seekTo(...)

```typescript
seekTo(options: SeekOptions) => Promise<void>
```

Seek to a specific position in the audio

| Param         | Type                                                |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#seekoptions">SeekOptions</a></code> |

--------------------


### getPlaybackStatus(...)

```typescript
getPlaybackStatus(options: PlayerOptions) => Promise<PlaybackStatusChangeEvent>
```

Get current playback status for a specific player

| Param         | Type                                                    |
| ------------- | ------------------------------------------------------- |
| **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#playbackstatuschangeevent">PlaybackStatusChangeEvent</a>&gt;</code>

--------------------


### getRecordingStatus(...)

```typescript
getRecordingStatus(options: RecorderOptions) => Promise<RecordingStatusChangeEvent>
```

Get current recording status for a specific recorder

| Param         | Type                                                        |
| ------------- | ----------------------------------------------------------- |
| **`options`** | <code><a href="#recorderoptions">RecorderOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#recordingstatuschangeevent">RecordingStatusChangeEvent</a>&gt;</code>

--------------------


### destroyRecorder(...)

```typescript
destroyRecorder(options: RecorderOptions) => Promise<void>
```

Destroy a recorder and release its resources

| Param         | Type                                                        |
| ------------- | ----------------------------------------------------------- |
| **`options`** | <code><a href="#recorderoptions">RecorderOptions</a></code> |

--------------------


### destroyPlayer(...)

```typescript
destroyPlayer(options: PlayerOptions) => Promise<void>
```

Destroy a player and release its resources

| Param         | Type                                                    |
| ------------- | ------------------------------------------------------- |
| **`options`** | <code><a href="#playeroptions">PlayerOptions</a></code> |

--------------------


### addListener('recordingStatusChange', ...)

```typescript
addListener(eventName: 'recordingStatusChange', listenerFunc: (event: RecordingStatusChangeEvent) => void) => Promise<PluginListenerHandle>
```

Listen for recording status changes

| Param              | Type                                                                                                  |
| ------------------ | ----------------------------------------------------------------------------------------------------- |
| **`eventName`**    | <code>'recordingStatusChange'</code>                                                                  |
| **`listenerFunc`** | <code>(event: <a href="#recordingstatuschangeevent">RecordingStatusChangeEvent</a>) =&gt; void</code> |

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>

--------------------


### addListener('playbackStatusChange', ...)

```typescript
addListener(eventName: 'playbackStatusChange', listenerFunc: (event: PlaybackStatusChangeEvent) => void) => Promise<PluginListenerHandle>
```

Listen for playback status changes (includes playerId to identify which player)

| Param              | Type                                                                                                |
| ------------------ | --------------------------------------------------------------------------------------------------- |
| **`eventName`**    | <code>'playbackStatusChange'</code>                                                                 |
| **`listenerFunc`** | <code>(event: <a href="#playbackstatuschangeevent">PlaybackStatusChangeEvent</a>) =&gt; void</code> |

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>

--------------------


### removeAllListeners()

```typescript
removeAllListeners() => Promise<void>
```

Remove all listeners

--------------------


### Interfaces


#### PermissionStatus

| Prop             | Type                                           |
| ---------------- | ---------------------------------------------- |
| **`microphone`** | <code>'granted' \| 'denied' \| 'prompt'</code> |


#### StartRecordResult

| Prop             | Type                | Description                                  |
| ---------------- | ------------------- | -------------------------------------------- |
| **`recorderId`** | <code>string</code> | Unique identifier for this recorder instance |


#### StartRecordOptions

| Prop       | Type                | Description                                                                                                                                             |
| ---------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`path`** | <code>string</code> | Optional relative path for the recording (including extension), relative to the app's data directory. If not provided, a default filename will be used. |


#### StopRecordResult

| Prop             | Type                | Description                               |
| ---------------- | ------------------- | ----------------------------------------- |
| **`recorderId`** | <code>string</code> | The recorder ID                           |
| **`path`**       | <code>string</code> | Path to the recorded file                 |
| **`duration`**   | <code>number</code> | Duration of the recording in milliseconds |


#### RecorderOptions

| Prop             | Type                | Description                               |
| ---------------- | ------------------- | ----------------------------------------- |
| **`recorderId`** | <code>string</code> | The recorder ID returned from startRecord |


#### PreparePlayResult

| Prop           | Type                | Description                                |
| -------------- | ------------------- | ------------------------------------------ |
| **`playerId`** | <code>string</code> | Unique identifier for this player instance |
| **`duration`** | <code>number</code> | Duration of the audio in milliseconds      |


#### PlayOptions

| Prop       | Type                | Description                                                                    |
| ---------- | ------------------- | ------------------------------------------------------------------------------ |
| **`path`** | <code>string</code> | Relative path to the audio file to play (relative to the app's data directory) |


#### PlayerOptions

| Prop           | Type                | Description                             |
| -------------- | ------------------- | --------------------------------------- |
| **`playerId`** | <code>string</code> | The player ID returned from preparePlay |


#### SeekOptions

| Prop           | Type                | Description                             |
| -------------- | ------------------- | --------------------------------------- |
| **`playerId`** | <code>string</code> | The player ID returned from preparePlay |
| **`position`** | <code>number</code> | Position to seek to in milliseconds     |


#### PlaybackStatusChangeEvent

| Prop                  | Type                                                      | Description                                 |
| --------------------- | --------------------------------------------------------- | ------------------------------------------- |
| **`playerId`**        | <code>string</code>                                       | The player ID this event belongs to         |
| **`status`**          | <code><a href="#playbackstatus">PlaybackStatus</a></code> |                                             |
| **`currentPosition`** | <code>number</code>                                       | Current playback position in milliseconds   |
| **`duration`**        | <code>number</code>                                       | Total duration of the audio in milliseconds |


#### RecordingStatusChangeEvent

| Prop             | Type                                                        | Description                                |
| ---------------- | ----------------------------------------------------------- | ------------------------------------------ |
| **`recorderId`** | <code>string</code>                                         | The recorder ID this event belongs to      |
| **`status`**     | <code><a href="#recordingstatus">RecordingStatus</a></code> |                                            |
| **`duration`**   | <code>number</code>                                         | Current recording duration in milliseconds |


#### PluginListenerHandle

| Prop         | Type                                      |
| ------------ | ----------------------------------------- |
| **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |


### Type Aliases


#### PlaybackStatus

<code>'playing' | 'paused' | 'stopped' | 'ended'</code>


#### RecordingStatus

<code>'recording' | 'paused' | 'stopped'</code>

</docgen-api>