AudioRecordStream
Constructors
new AudioRecordStream()
new AudioRecordStream(
id
):AudioRecordStream
Creates a new AudioRecordStream instance. This constructor Must not be called directly. Use AudioRecordStreamBuilder.AudioRecordStreamBuilder.buildAsync to create instances.
Parameters
id
number
Internal stream identifier
Returns
Properties
streamId
streamId:
number
Methods
flushAsync()
flushAsync():
Promise
<AudioStatus
>
Flushes the record buffer, discarding any unread data.
Returns
Promise
<AudioStatus
>
A promise that resolves to:
STATUS_NO_ERROR (0)
: Successfully flushedSTATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getAudioConfigAsync()
getAudioConfigAsync():
Promise
<AudioConfig
>
Retrieves the current audio configuration of the record stream.
Returns
Promise
<AudioConfig
>
A promise that resolves to an AudioConfig object containing:
sampleRate
: Current sample rate in HzchannelMask
: Current channel configurationformat
: Current sample format Or rejects with:STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getAudioEffectSessionIdAsync()
getAudioEffectSessionIdAsync():
Promise
<number
>
Gets the custom audio effect session ID associated with this stream.
Returns
Promise
<number
>
A promise that resolves to:
- Positive value: The effect session ID
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_BAD_VALUE (-2)
: No effect session assigned
getAudioFlagsAsync()
getAudioFlagsAsync():
Promise
<number
>
Gets the audio flags configured for this stream.
Returns
Promise
<number
>
A promise that resolves to:
- Bitwise combination of AudioFlags values
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getAudioSourceAsync()
getAudioSourceAsync():
Promise
<AudioSource
>
Gets the audio source type configured for this stream.
Returns
Promise
<AudioSource
>
A promise that resolves to:
- AudioSource enum value indicating the current source Or rejects with:
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getChannelCountAsync()
getChannelCountAsync():
Promise
<number
>
Gets the channel count of the record stream.
Returns
Promise
<number
>
A promise that resolves to:
- Positive value: Number of channels
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getLatencyInMsAsync()
getLatencyInMsAsync():
Promise
<number
>
Gets the current latency of the record stream in milliseconds.
Returns
Promise
<number
>
A promise that resolves to:
- Positive value: Latency in milliseconds
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getMinBufferSizeInBytesAsync()
getMinBufferSizeInBytesAsync():
Promise
<number
>
Gets the minimum buffer size required for recording. readAsync calls must use at least this size for reliable recording.
Returns
Promise
<number
>
A promise that resolves to:
- Positive value: Minimum buffer size in bytes
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getNumBytesInPipelineAsync()
getNumBytesInPipelineAsync():
Promise
<number
>
Gets the number of bytes currently in the recording pipeline.
Returns
Promise
<number
>
A promise that resolves to:
- Positive value: Number of bytes in pipeline
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getNumBytesOfNativeBufferAsync()
getNumBytesOfNativeBufferAsync():
Promise
<number
>
Gets the size of the native buffer used for recording. This represents the maximum amount of data that can be buffered.
Returns
Promise
<number
>
A promise that resolves to:
- Positive value: Buffer size in bytes
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getSampleRateAsync()
getSampleRateAsync():
Promise
<number
>
Gets the sample rate of the record stream.
Returns
Promise
<number
>
A promise that resolves to:
- Positive value: Sample rate in Hz
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
getSampleSizeAsync()
getSampleSizeAsync():
Promise
<number
>
Gets the sample size in bits of the record stream.
Returns
Promise
<number
>
A promise that resolves to:
- Positive value: Sample size in bits (e.g., 16, 24, 32)
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_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
>
A promise that resolves to:
STATUS_NO_ERROR (0)
: Stream is properly initializedSTATUS_NO_INIT (-3)
: Stream not initializedSTATUS_DEAD_OBJECT (-5)
: Server communication error
readAsync()
readAsync(
bytes
):Promise
<ArrayBuffer
>
Reads audio data from the record stream.
Requires privilege: com.amazon.audio.privilege.microphone.access
Parameters
bytes
number
Number of bytes to read. Must be at least the value returned by getMinBufferSizeInBytesAsync
Returns
Promise
<ArrayBuffer
>
A promise that resolves to:
- ArrayBuffer containing the recorded audio data Or rejects with:
STATUS_NO_INIT (-3)
: Stream not initializedSTATUS_BAD_VALUE (-2)
: Invalid bytes parameterSTATUS_PERMISSION_DENIED (-9)
: Missing microphone privilegeSTATUS_INVALID_OPERATION (-8)
: Read operation failedSTATUS_DEAD_OBJECT (-5)
: Server communication error
registerEventObserverAsync()
registerEventObserverAsync(
callback
):Promise
<AudioStatus
>
Registers a callback to receive record stream events. Only one callback can be registered at a time.
Parameters
callback
(value
) => void
Function to receive events. Events include:
DIED (0)
: Stream has failedRECOVERED (1)
: Stream has recovered from failureMUTE_STATE_CHANGED (2)
: Stream mute state changed
Returns
Promise
<AudioStatus
>
A promise that resolves to:
STATUS_NO_ERROR (0)
: Callback registered successfullySTATUS_NO_INIT (-3)
: Stream not initializedSTATUS_BAD_VALUE (-2)
: Invalid callbackSTATUS_ALREADY_EXISTS (-4)
: Callback already registered
unregisterEventObserverAsync()
unregisterEventObserverAsync():
Promise
<AudioStatus
>
Unregister the previously registered event callback.
Returns
Promise
<AudioStatus
>
A promise that resolves to:
STATUS_NO_ERROR (0)
: Callback unregistered successfullySTATUS_NO_INIT (-3)
: Stream not initializedSTATUS_BAD_VALUE (-2)
: No callback was registered
getMajorVersion()
static
getMajorVersion():number
Gets the major version number of the AudioRecordStream implementation. Can be used to make version checks.
Returns
number
The major version number
getMinorVersion()
static
getMinorVersion():number
Gets the minor version number of the AudioRecordStream implementation. Can be used to make version checks.
Returns
number
The minor version number
getPatchVersion()
static
getPatchVersion():number
Gets the patch version number of the AudioRecordStream implementation. Can be used to make version checks.
Returns
number
The patch version number
Last updated: Sep 30, 2025