onRecordingEvent(listener: Function)

Requires:
BaseKit≥2.3.2@ray-js/ray≥0.3.23
Platforms:
iOSAndroid
import { onRecordingEvent } from '@ray-js/ray';

// Promise usage
try {
  const res = await onRecordingEvent({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Continuous recording event

Parameters

ParameterTypeRequiredDescription
Yes

Return Value

None

Examples

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);
  },
});