---
name: "onRecordingEvent"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.3.2" }
platform:
  - "iOS"
  - "Android"
async: true
---

## onRecordingEvent

> [VERSION] BaseKit >= 2.3.2

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Continuous recording event

### Parameters

`(listener: Function)`

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `listener` | `(params: AudioRecordBufferBean) => void` | Yes | - | Event listener callback function |

### Referenced Types

##### `interface` AudioRecordBufferBean

| Property | Type | Required | Since | Description |
| --- | --- | --- | --- | --- |
| `buffer` | `number[]` | Yes | `2.3.2` | Data stream |


### Examples

```tsx
const manager = await ty.getRecorderManager();

let stopped = false;
ty.onRecordingEvent(e => {
  console.log(e);
  // Stop after receiving the first audio data event; the event is triggered and self-cleaned.
  if (!stopped) {
    stopped = true;
    manager.stopRecording({ success: () => {}, fail: () => {} });
  }
});

// Start continuous recording to produce onRecordingEvent callbacks.
manager.startRecording({
  period: 200,
  pcm16IOS: true,
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});
```
