Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Skip to main content
Audio Playback Stream allows for control of playback streams such as pausing, flushing, and writing to the playback buffer.
  • TOC

Required privileges

The API requires specific privileges for certain operations:
The API also requires declaration of the system audio services:

Types Used

Refer to Audio core types
  • AudioStatus
  • AudioAttributes
  • AudioConfig
  • AudioPlaybackEvent
  • AudioVolumeType
  • StreamDuckingPolicy
  • DuckingMode

Methods

initCheckAsync()

Description

Checks if the playback stream has been initialized.

Return Value

Returns a promise resolving to an AudioStatus type.

Example code

getAudioConfigAsync()

Description

Gets the audio configuration of a playback stream.

Return Value

Returns a promise resolving to an AudioConfig object.

Example code

getAudioAttributesAsync()

Description

Gets the audio attributes of a playback stream.

Return Value

Returns a promise resolving to an AudioAttributes object.

Example code

getSampleRateAsync()

Description

Gets the sample rate of a playback stream.

Return Value

Returns a promise resolving to an Int32 representing the sample rate.

Example code

getChannelCountAsync()

Description

Gets the channel count of a playback stream.

Return Value

Returns a promise resolving to an Int32 representing the channel count.

Example code

getSampleSizeAsync(**)

Description

Gets the sample size of a playback stream.

Return Value

Returns a promise resolving to an Int32 representing the sample size.

Example code

getNumBytesInPipelineAsync()

Description

Gets the number of bytes in the pipeline waiting to be consumed by audio pipeline between clients and audio server.

Return Value

Returns a promise resolving to an Int32 representing the number of bytes in the pipeline.

Example code

getNumBytesOfNativeBufferAsync()

Description

Gets the number of bytes representing the size of the shared buffer between the client and audio server.

Return Value

Returns a promise resolving to an Int32 representing the number of bytes in the native buffer.

Example code

getFramesPerBufferAsync()

Description

Gets the number of frames per buffer.

Return Value

Returns a promise resolving to an Int32 representing the frames per buffer.

Example code

getAudioFocusSessionIdAsync()

Description

Gets the focus session ID.

Return Value

Returns a promise resolving to an Int32 representing the focus session ID.

Example code

getLatencyInMsAsync()

Description

Gets the latency in milliseconds.

Return Value

Returns a promise resolving to an Int32 representing the latency in milliseconds.

Example code

pauseAsync()

Description

Pauses the playback stream.

Return Value

Returns a promise that resolves to an AudioStatus type.

Example code

startAsync()

Description

Starts the playback stream.

Return Value

Returns a promise that resolves to an AudioStatus type.

Example code

stopAsync()

Description

Stops the playback stream.

Return Value

Returns a promise that resolves to an AudioStatus type.

Example code

flushAsync()

Description

Flushes the playback stream.

Return Value

Returns a promise that resolves to an AudioStatus type.

Example code

registerEventObserverAsync(callback)

Description

Registers a callback function that executes anytime an audio change event is detected. Only one callback function can be registered at a time.

Return Value

Returns a promise that resolves to an AudioStatus type

Parameters

Example code

unregisterEventObserverAsync(**)

Description

Unregisters any callback function that is currently registered.

Return Value

Returns a promise that resolves to an AudioStatus type.

Example code

writeAsync(buffer)

Description

Writes to the playback buffer using bytes stored in buffer parameter.

Return Value

Returns a promise that resolves to an AudioStatus type.

Parameters

Example code

getUnderrunSizeAsync()

Description

Get API for querying underrun size. If a client has set a buffer underrun threshold and playback buffer is in underrun state, this API will return the difference between the buffer size and the threshold value. Otherwise, this API will return 0.

Return Value

Returns a promise (Int32) with difference in frames between buffer size and underrun threshold. Frame value is rounded up.

Example code

getUnderrunCountAsync()

Description

Get API for querying number of underruns that occurred during stream lifetime.

Return Value

Returns a promise (Int32) with number of underrun ocurrences that occurred during stream lifetime.

Example code

getPresentedFrameCountAsync()

Description

Query api for number of audio frames already presented and accepted by audio pipeline.

Return Value

Returns a promise (Int32) with number of audio frames presented to audio pipeline on success.

Example code

getDuckingPolicyAsync()

Description

Query api for number of audio frames already presented and accepted by audio pipeline.

Return Value

Returns a promise (Int32) with the duckingPolicy for the current AudioPlaybackStream object

Example code

duckVolumeAsync(mode, value, rampDuration)

Description

Api to duck/unduck the stream by specified db/percentage duck/unduck volume based on specific stream instance’s volume.

Return Value

Returns a promise that resolves to an AudioStatus type (Int32).

Parameters

Example code

setVolumeAsync(gain)

Description

Set individual stream volume by absolute gain in percentage.set gain of individual stream; It will be multiplied on stream volume.

Return Value

Returns a promise (Int32) with the duckingPolicy for the current AudioPlaybackStream object

Parameters

Example code

getVolumeAsync()

Description

Set individual stream volume by absolute gain in percentage.set gain of individual stream; It will be multiplied on stream volume.

Return Value

Returns a promise (Int32) with the duckingPolicy for the current AudioPlaybackStream object

Parameters

| Parameter Name | Type | Required | Description | | ————– | —- | ——– | ———– |

Example code


Last modified on October 2, 2025