as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

AudioRecordStream

Constructors

new AudioRecordStream()

new AudioRecordStream(id): AudioRecordStream

Parameters

id

number

Internal stream identifier

Returns

AudioRecordStream

Properties

streamId

streamId: number

Methods

flushAsync()

flushAsync(): Promise<AudioStatus>

Flushes the record buffer, discarding any unread data.

Returns

Promise<AudioStatus>

Promise A promise that resolves to:

  • STATUS_NO_ERROR (0): Successfully flushed
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getAudioConfigAsync()

getAudioConfigAsync(): Promise<AudioConfig>

Retrieves the current audio configuration of the record stream.

Returns

Promise<AudioConfig>

Promise A promise that resolves to an object containing:

  • sampleRate: Current sample rate in Hz
  • channelMask: Current channel configuration
  • format: Current sample format Or rejects with:
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getAudioEffectSessionIdAsync()

getAudioEffectSessionIdAsync(): Promise<Int32>

Gets the custom audio effect session ID associated with this stream.

Returns

Promise<Int32>

Promise A promise that resolves to:

  • Positive value: The effect session ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_BAD_VALUE (-2): No effect session assigned

getAudioFlagsAsync()

getAudioFlagsAsync(): Promise<Int32>

Gets the audio flags configured for this stream.

Returns

Promise<Int32>

Promise A promise that resolves to:

  • Bitwise combination of AudioFlags values
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getAudioSourceAsync()

getAudioSourceAsync(): Promise<AudioSource>

Gets the audio source type configured for this stream.

Returns

Promise<AudioSource>

Promise A promise that resolves to:

  • enum value indicating the current source Or rejects with:
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getChannelCountAsync()

getChannelCountAsync(): Promise<Int32>

Gets the channel count of the record stream.

Returns

Promise<Int32>

Promise A promise that resolves to:

  • Positive value: Number of channels
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getLatencyInMsAsync()

getLatencyInMsAsync(): Promise<Int32>

Gets the current latency of the record stream in milliseconds.

Returns

Promise<Int32>

Promise A promise that resolves to:

  • Positive value: Latency in milliseconds
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getMajorVersion()

static getMajorVersion(): number

Gets the major version number of the implementation. Can be used to make version checks.

Returns

number

number The major version number


getMinBufferSizeInBytesAsync()

getMinBufferSizeInBytesAsync(): Promise<Int32>

Gets the minimum buffer size required for recording. calls must use at least this size for reliable recording.

Returns

Promise<Int32>

Promise A promise that resolves to:

  • Positive value: Minimum buffer size in bytes
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getMinorVersion()

static getMinorVersion(): number

Gets the minor version number of the implementation. Can be used to make version checks.

Returns

number

number The minor version number


getNumBytesInPipelineAsync()

getNumBytesInPipelineAsync(): Promise<Int32>

Gets the number of bytes currently in the recording pipeline.

Returns

Promise<Int32>

Promise A promise that resolves to:

  • Positive value: Number of bytes in pipeline
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getNumBytesOfNativeBufferAsync()

getNumBytesOfNativeBufferAsync(): Promise<Int32>

Gets the size of the native buffer used for recording. This represents the maximum amount of data that can be buffered.

Returns

Promise<Int32>

Promise A promise that resolves to:

  • Positive value: Buffer size in bytes
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getPatchVersion()

static getPatchVersion(): number

Gets the patch version number of the implementation. Can be used to make version checks.

Returns

number

number The patch version number


getSampleRateAsync()

getSampleRateAsync(): Promise<Int32>

Gets the sample rate of the record stream.

Returns

Promise<Int32>

Promise A promise that resolves to:

  • Positive value: Sample rate in Hz
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

getSampleSizeAsync()

getSampleSizeAsync(): Promise<Int32>

Gets the sample size in bits of the record stream.

Returns

Promise<Int32>

Promise A promise that resolves to:

  • Positive value: Sample size in bits (e.g., 16, 24, 32)
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

initCheckAsync()

initCheckAsync(): Promise<AudioStatus>

Verifies if the record stream has been properly initialized. Must be called before using other methods to ensure the stream is ready.

Returns

Promise<AudioStatus>

Promise A promise that resolves to:

  • STATUS_NO_ERROR (0): Stream is properly initialized
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server communication error

readAsync()

readAsync(bytes: Int32): Promise<ArrayBuffer>

Reads audio data from the record stream. Requires privilege: com.amazon.audio.privilege.microphone.access

Parameters

bytes

Int32

Number of bytes to read. Must be at least the value returned by

Returns

Promise<ArrayBuffer>

Promise A promise that resolves to:

  • ArrayBuffer containing the recorded audio data Or rejects with:
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_BAD_VALUE (-2): Invalid bytes parameter
  • STATUS_PERMISSION_DENIED (-9): Missing microphone privilege
  • STATUS_INVALID_OPERATION (-8): Read operation failed
  • STATUS_DEAD_OBJECT (-5): Server communication error

registerEventObserverAsync()

registerEventObserverAsync(callback: (value: any) => void): Promise<AudioStatus>

Registers a callback to receive record stream events. Only one callback can be registered at a time.

Parameters

callback

(value: any) => void

Function to receive events. Events include:

  • DIED (0): Stream has failed
  • RECOVERED (1): Stream has recovered from failure
  • MUTE_STATE_CHANGED (2): Stream mute state changed

Returns

Promise<AudioStatus>

Promise A promise that resolves to:

  • STATUS_NO_ERROR (0): Callback registered successfully
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_BAD_VALUE (-2): Invalid callback
  • STATUS_ALREADY_EXISTS (-4): Callback already registered

unregisterEventObserverAsync()

unregisterEventObserverAsync(): Promise<AudioStatus>

Unregister the previously registered event callback.

Returns

Promise<AudioStatus>

Promise A promise that resolves to:

  • STATUS_NO_ERROR (0): Callback unregistered successfully
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_BAD_VALUE (-2): No callback was registered

Last updated: Jul 22, 2026