---
name: "onRecordingEvent"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.3.2" }
  - { name: "@ray-js/ray", version: "0.3.23" }
platform:
  - "iOS"
  - "Android"
async: true
---

## onRecordingEvent

> [VERSION] BaseKit >= 2.3.2 | @ray-js/ray >= 0.3.23

> [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 | - |  |

### Referenced Types

##### `interface` AudioRecordBufferBean

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


### Examples

#### Demo

```tsx
import { getRecorderManager, onRecordingEvent } from '@ray-js/ray'

const manager = await getRecorderManager();

let stopped = false;
onRecordingEvent(e => {
  console.log(e);
  // Stop after receiving the first recording data event; the event has fired and is self-cleaning.
  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);
  },
});
```
