RecorderManager.start

Start recording.

Parameters

Property

Type

Required

Description

duration

Number

No

The recording duration, in ms.

Max: 600000 (10 minutes)

Default: 600000

format

String

No

The audio format. The value must be in lowercase.

Valid values: aac and pcm

Default: aac

hideTips

Boolean

No

Whether to hide the recording icon.

Default: false

numberOfChannels

Number

No

The number of recording channels.

Valid values: 1 and 2

Default: 1

sampleRate

Number

No

The sampling rate.

Valid values: 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, and 48000

Default:

  • 8000 (Android)
  • 44100 (iOS)

encodeBitRate

Number

No

The encoding bitrate. The encoding bitrate must be configured based on the sampling rate you configure. For more information, see Encoding bitrate ranges

Default:

  • 32000 (Android)
  • 192000 (iOS)

audioSource

String

No

The audio input source for recording. You can call the my.getAvailableAudioSources API to get the available audio sources.

Default: auto

frameSize

Number

No

The frame size, in KB.

The FrameRecorded event listened to via RecorderManager.onFrameRecorded will only be triggered if frameSize is specified and frameFormatPcm is set to true.

frameFormatPcm

Boolean

No

Whether the recorded audio frames should be formatted in Pulse Code Modulation (PCM).

The FrameRecorded event listened to via RecorderManager.onFrameRecorded will be triggered only if frameFormatPcm is set to true and frameSize is specified.

Encoding bitrate ranges

Each sampling rate corresponds to a valid range of encoding bitrates. Setting an invalid sampling rate or encoding bitrate will result in a recording failure. The following table shows the correspondence:

Sampling rate

Encoding bitrate range

8000

16000–48000

11025

16000–48000

12000

24000–64000

16000

24000–96000

22050

32000–128000

24000

32000–128000

32000

48000–192000

44100

64000–320000

48000

64000–320000

Sample code

copy
const recorderManager = my.getRecorderManager();
recorderManager.start({
  duration: 60000,
});