Constructors
new AudioRecordStream()
new AudioRecordStream(id): AudioRecordStream
Parameters
id
number
Internal stream identifier
Returns
AudioRecordStreamProperties
streamId
streamId: number
Methods
flushAsync()
flushAsync():Flushes the record buffer, discarding any unread data.Promise<AudioStatus>
Returns
Promise<AudioStatus>
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():Retrieves the current audio configuration of the record stream.Promise<AudioConfig>
Returns
Promise<AudioConfig>
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<Int32>
Gets the custom audio effect session ID associated with this stream.
Returns
Promise<Int32>
Promise<Int32> 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<Int32>
Gets the audio flags configured for this stream.
Returns
Promise<Int32>
Promise<Int32> 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():Gets the audio source type configured for this stream.Promise<AudioSource>
Returns
Promise<AudioSource>
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<Int32>
Gets the channel count of the record stream.
Returns
Promise<Int32>
Promise<Int32> 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<Int32>
Gets the current latency of the record stream in milliseconds.
Returns
Promise<Int32>
Promise<Int32> A promise that resolves to:
- Positive value: Latency in milliseconds
STATUS_NO_INIT (-3): Stream not initializedSTATUS_DEAD_OBJECT (-5): Server communication error
getMajorVersion()
Gets the major version number of the AudioRecordStream implementation. Can be used to make version checks.staticgetMajorVersion():number
Returns
number
number The major version number
getMinBufferSizeInBytesAsync()
getMinBufferSizeInBytesAsync(): Promise<Int32>
Gets the minimum buffer size required for recording.
readAsync calls must use at least this size for reliable recording.
Returns
Promise<Int32>
Promise<Int32> 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
getMinorVersion()
Gets the minor version number of the AudioRecordStream implementation. Can be used to make version checks.staticgetMinorVersion():number
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<Int32> 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<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<Int32> A promise that resolves to:
- Positive value: Buffer size in bytes
STATUS_NO_INIT (-3): Stream not initializedSTATUS_DEAD_OBJECT (-5): Server communication error
getPatchVersion()
Gets the patch version number of the AudioRecordStream implementation. Can be used to make version checks.staticgetPatchVersion():number
Returns
number
number The patch version number
getSampleRateAsync()
getSampleRateAsync(): Promise<Int32>
Gets the sample rate of the record stream.
Returns
Promise<Int32>
Promise<Int32> 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<Int32>
Gets the sample size in bits of the record stream.
Returns
Promise<Int32>
Promise<Int32> 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():Verifies if the record stream has been properly initialized. Must be called before using other methods to ensure the stream is ready.Promise<AudioStatus>
Returns
Promise<AudioStatus>
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:Reads audio data from the record stream. Requires privilege:Int32):Promise<ArrayBuffer>
com.amazon.audio.privilege.microphone.access
Parameters
bytes
Int32
Number of bytes to read. Must be at least the value returned
by getMinBufferSizeInBytesAsync
Returns
Promise<ArrayBuffer>
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:Registers a callback to receive record stream events. Only one callback can be registered at a time.(value: any) => void):Promise<AudioStatus>
Parameters
callback
(value: any) => 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>
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():Unregister the previously registered event callback.Promise<AudioStatus>
Returns
Promise<AudioStatus>
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

