AudioManager
Audio Manager allows audio management such as volume adjustment and mute control.
Required privileges
The API requires specific privileges for certain operations:
[[needs.privilege]]
id = "com.amazon.audio.privilege.settings.control"
The API also requires declaration of the system audio service:
[wants]
[[wants.service]]
id = "com.amazon.audio.control"
Types Used
Refer to
- *
Constructors
new AudioManager()
new AudioManager(): AudioManager
Returns
Methods
allocateCustomAudioEffectSessionAsync()
staticallocateCustomAudioEffectSessionAsync():Promise<Int32>
Creates a unique session ID for custom audio effects. This ID can be used to associate audio effects with specific playback or record streams.
Returns
Promise<Int32>
Promise A promise that resolves to:
- Positive number: New unique session ID
Rejects with:
- (-1): Failed to allocate session
- (-5): Server connection lost
areSystemSoundsEnabledAsync()
staticareSystemSoundsEnabledAsync():Promise<boolean>
Checks if system sounds are currently enabled.
Returns
Promise<boolean>
Promise A promise that resolves to:
true: System sounds are enabledfalse: System sounds are disabled
Rejects with:
- (-5): Server connection lost
disableAvrcpAbsoluteVolumeAsync()
staticdisableAvrcpAbsoluteVolumeAsync(btAddress:String):Promise<AudioStatus>
Disables AVRCP absolute volume control for a Bluetooth device. When disabled, volume control is handled by the system.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
btAddress
String
Bluetooth device address
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid address
- (-9): Missing privilege
- (-8): Device doesn't support AVRCP
- (-5): Server connection lost
disableSystemSoundsAsync()
staticdisableSystemSoundsAsync():Promise<AudioStatus>
Disables all system sounds. System sounds will not play until re-enabled with .
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-5): Server connection lost
- (-8): Operation failed
disableUsageAsync()
staticdisableUsageAsync(usage:Int32):Promise<AudioStatus>
Disables audio playback for a specific usage type.
Currently only supports USAGE_NOTIFICATION.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
usage
Int32
Usage type to disable
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid or unsupported usage type
- (-9): Missing privilege
- (-5): Server connection lost
enableAvrcpAbsoluteVolumeAsync()
staticenableAvrcpAbsoluteVolumeAsync(btAddress:String):Promise<AudioStatus>
Enables AVRCP absolute volume control for a Bluetooth device. When enabled, volume control is handled by the Bluetooth device itself.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
btAddress
String
Bluetooth device address
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid address
- (-9): Missing privilege
- (-8): Device doesn't support AVRCP
- (-5): Server connection lost
enableSystemSoundsAsync()
staticenableSystemSoundsAsync():Promise<AudioStatus>
Enables system sounds after they have been disabled. System sounds are enabled by default.
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-5): Server connection lost
- (-8): Operation failed
enableUsageAsync()
staticenableUsageAsync(usage:Int32):Promise<AudioStatus>
Enables audio playback for a specific usage type.
Currently only supports USAGE_NOTIFICATION.
When setting other usages, the function will throw
"[com.amazon.apmf.SecurityError]: No Permission" exception.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
usage
Int32
Usage type to enable
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid or unsupported usage type
- (-9): Missing privilege
- (-5): Server connection lost
getAudioDeviceListAsync()
staticgetAudioDeviceListAsync(device: AudioDevice, role: AudioRole):Promise<AudioDeviceInfo[]>
Gets a list of available audio devices matching the specified role.
Parameters
device
Device type to filter by, or DEVICE_ALL for all devices. Values:
- (0x0)
- (1 30)
- (1 0)
- (1 1)
- (1 2)
- (1 3)
- And others as defined in enum
role
Role to filter by. Values:
- (0): Input devices
- (1): Output devices
- (2): Both input and output devices
Returns
Promise<AudioDeviceInfo[]>
PromiseAudioDeviceInfo[] A promise that resolves to an array of AudioDeviceInfo objects:
Each object contains:
role: AudioRoletype: AudioDevicename: stringformats: AudioSampleFormat[]sampleRates: AudioSampleRate[]channelMasks: AudioChannelMask[]
Rejects with:
- (-2): Invalid parameters
- (-5): Server connection lost
getGlobalVolumeMuteAsync()
staticgetGlobalVolumeMuteAsync():Promise<boolean>
Gets the current global volume mute state.
Returns
Promise<boolean>
Promise A promise that resolves to:
true: Global mute is enabledfalse: Global mute is disabled
Rejects with:
- (-5): Server connection lost
Examples
/*
Gets global mute status and stores the boolean in global_mute after promise resolves
*\/
const global_mute = AudioManager.getGlobalVolumeMuteAsync().then((global_mute) => {return global_mute;}).catch((error) => console.log(error));
getMajorVersion()
staticgetMajorVersion():number
Gets the major version number of the . Can be used to make version checks.
Returns
number
number The major version number
getMaxVolumeAsync()
staticgetMaxVolumeAsync():Promise<Int32>
Gets the current maximum volume limit.
Returns
Promise<Int32>
Promise A promise that resolves to:
- 0-100: Current maximum volume limit
Rejects with:
- (-5): Server connection lost
Examples
const testGetMaxVolume = async () => {
let maxVolume = await AudioManager.getMaxVolumeAsync();
console.log("getMaxVolumeAsync(): SUCCESS, Max volume: ", maxVolume);
};
getMicMuteAsync()
staticgetMicMuteAsync():Promise<boolean>
Gets the current microphone mute state.
Returns
Promise<boolean>
Promise A promise that resolves to:
true: Microphone is mutedfalse: Microphone is not muted
Rejects with:
- (-5): Server connection lost
Examples
/*
Gets mute status of microphone input and stores the returned boolean in mute_status
after promise resolves
*\/
const mute_status = AudioManager.getMicMuteAsync()
.then((mute_status) => {return mute_status;}).catch((error) => console.log(error));
getMinorVersion()
staticgetMinorVersion():number
Gets the minor version number of the . Can be used to make version checks.
Returns
number
number The minor version number
getMuteAsync()
staticgetMuteAsync(volType: AudioVolumeType):Promise<boolean>
Gets the system-wide mute state for a specific volume type.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
volType
Volume type to query. See for types.
Returns
Promise<boolean>
Promise A promise that resolves to:
true: Volume type is mutedfalse: Volume type is not muted
Rejects with:
- (-2): Invalid volume type
- (-9): Missing privilege
- (-5): Server connection lost
Examples
const testGetMuteAsync = async () => {
let muteStatus = await AudioManager.setMuteAsync(AudioVolumeType.VOLUME_TYPE_MEDIA);
console.log("setMuteAsync(): SUCCESS, Mute state: ", Boolean(muteStatus));
};
getPatchVersion()
staticgetPatchVersion():number
Gets the patch version number of the . Can be used to make version checks.
Returns
number
number The patch version number
getSinkFormatsSelectionPolicyAsync()
staticgetSinkFormatsSelectionPolicyAsync():Promise<Int32>
Gets the current policy for selecting audio output formats.
Returns
Promise<Int32>
Promise A promise that resolves to:
- SinkFormatsSelectionPolicy value. See
Rejects with:
- (-5): Server connection lost
Examples
const testGetSinkFormatsSelectionPolicyAsync = async () => {
let currentSinkPolicy = await AudioManager.getSinkFormatsSelectionPolicyAsync();
console.log("getSinkFormatsSelectionPolicyAsync() Current format: ", currentSinkPolicy);
};
getSupportedPlaybackConfigurationsAsync()
staticgetSupportedPlaybackConfigurationsAsync(attributes: AudioAttributes, deviceType:Int32):Promise<AudioConfigAttr[]>
Gets the supported audio configurations for playback with given attributes and device. Use this to determine valid combinations of format, sample rate, and channels.
Parameters
attributes
Audio attributes defining content type and usage
deviceType
Int32
Device type to query, use DEVICE_DEFAULT for current output
Returns
Promise<AudioConfigAttr[]>
PromiseAudioConfigAttr[] A promise that resolves to an array of supported configurations:
Each config contains:
sampleRate: AudioSampleRatechannelMask: AudioChannelMaskformat: AudioSampleFormatlayout: SampleLayout
Rejects with:
- (-2): Invalid parameters
- (-0): No configurations available
- (-5): Server connection lost
Examples
let supportedAudioConfigs = await AudioManager.getSupportedPlaybackConfigurationsAsync(configAttr, AudioDevice.DEVICE_DEFAULT);
for (let audioConfig: supportedAudioConfigs) {
console.log("format", audioConfig.format);
console.log("sample rate", audioConfig.sampleRate);
console.log("channel mask", audioConfig.channelMask);
console.log("layout", audioConfig.layout);
}
getSupportedRecordConfigurationsAsync()
staticgetSupportedRecordConfigurationsAsync(excludeDisconnectedDevice:boolean, sourceType:Int32):Promise<AudioConfigAttr[]>
Gets supported audio configurations for recording. Use this to determine valid combinations of format, sample rate, and channels for recording.
Parameters
excludeDisconnectedDevice
boolean
When true, only returns configurations for connected devices. When false, returns all supported configurations from config files.
sourceType
Int32
Audio source type to query configurations for
Returns
Promise<AudioConfigAttr[]>
PromiseAudioConfigAttr[] A promise that resolves to an array of supported configurations:
Each config contains:
sampleRate: AudioSampleRatechannelMask: AudioChannelMaskformat: AudioSampleFormatlayout: SampleLayout
Rejects with:
- (-2): Invalid parameters
- (-0): No configurations available
- (-5): Server connection lost
getSupportedSinkFormatsSelectionPoliciesAsync()
staticgetSupportedSinkFormatsSelectionPoliciesAsync():Promise<SinkPolicies[]>
Gets a list of supported sink format selection policies. Not all devices support all policies - use this to determine available options.
Returns
Promise<SinkPolicies[]>
PromiseSinkPolicies[] A promise that resolves to an array of supported policies:
Each entry contains:
- policy: number (
SinkFormatsSelectionPolicyvalue)
Rejects with:
- (-5): Server connection lost
Examples
const testGetSupportedSinkFormatsSelectionPoliciesAsync = async () => {
let supportedSinkFormats = await AudioManager.getSupportedSinkFormatsSelectionPoliciesAsync();
if (supportedSinkFormats.length > 0) {
supportedSinkFormats.forEach(data => {
console.log("Supported policy (integer representation): ", parseInt(data), "\n");
});
}
};
getSystemSoundThemeAsync()
staticgetSystemSoundThemeAsync():Promise<String>
Gets the currently active system sound theme.
Returns
Promise<String>
Promise A promise that resolves to:
- String: Current theme identifier
Rejects with:
- (-1): No theme set
- (-5): Server connection lost
getSystemSoundThemeListAsync()
staticgetSystemSoundThemeListAsync():Promise<AudioTheme[]>
Gets a list of all supported system sound themes. System sound themes define different sets of sounds for system events.
Returns
Promise<AudioTheme[]>
PromiseAudioTheme[] A promise that resolves to an array of AudioTheme objects:
Each object contains:
theme: string (theme identifier)
Rejects with:
- (-1): Theme files not found
- (-5): Server connection lost
getTelephonyMuteAsync()
staticgetTelephonyMuteAsync(device: AudioDevice, address:String):Promise<boolean>
Gets the mute state for telephony audio on a specific device.
Parameters
device
Device to query
address
String
Unique identifier for the device.
Returns
Promise<boolean>
Promise A promise that resolves to:
true: Telephony audio is mutedfalse: Telephony audio is not muted
Rejects with:
- (-2): Invalid parameters
- (-8): Device not in telephony mode
- (-5): Server connection lost
Examples
let muteStatus = await AudioManager.getTelephonyMuteAsync(AudioDevice.DEVICE_TELEPHONY, "0X859978AF");
console.log("getTelephonyMuteAsync(): SUCCESS, Mute state: ", Boolean(muteStatus));
getVolumeAsync()
staticgetVolumeAsync(type: AudioVolumeType):Promise<Int32>
Gets the current system-wide volume level for a specific audio type.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
type
The audio type to query. See for types.
Returns
Promise<Int32>
Promise A promise that resolves to:
- 0-100: Current volume level
- (-2): Invalid type
- (-9): Missing privilege
- (-5): Server connection lost
Examples
/*
Retrieves volume percent of audio type media and stores it in volume after promise resolves
*\/
const volume = AudioManager.getVolumeAsync(AudioVolumeType.VOLUME_TYPE_MEDIA)
.then((volume) => {return volume;}).catch((error) => console.log(error));
isAvrcpAbsoluteVolumeEnabledAsync()
staticisAvrcpAbsoluteVolumeEnabledAsync(btAddress:String):Promise<boolean>
Checks if AVRCP absolute volume control is enabled for a Bluetooth device.
Parameters
btAddress
String
Bluetooth device address
Returns
Promise<boolean>
Promise A promise that resolves to:
true: AVRCP absolute volume is enabledfalse: AVRCP absolute volume is disabled Rejects with:- (-2): Invalid address
- (-8): Device doesn't support AVRCP
- (-5): Server connection lost
isServerReadyAsync()
staticisServerReadyAsync():Promise<boolean>
Checks if the audio server is ready to process commands.
Returns
Promise<boolean>
Promise A promise that resolves to:
true: Server is readyfalse: Server is not ready
Rejects with:
- (-5): Server connection lost
Examples
//Returns true if server is ready to receive commands, false if not ready
const server_ready = AudioManager.isServerReadyAsync()
.then((ready) => {return ready;}).catch((error) => console.log(error));
isUsageEnabledAsync()
staticisUsageEnabledAsync(usage:Int32):Promise<boolean>
Checks if audio playback is enabled for a specific usage type.
Parameters
usage
Int32
Usage type to query
Returns
Promise<boolean>
Promise A promise that resolves to:
true: Usage type is enabledfalse: Usage type is disabled
Rejects with:
- (-2): Invalid usage type
- (-5): Server connection lost
playSystemSoundAsync()
staticplaySystemSoundAsync(soundType: AudioSystemSound):Promise<AudioStatus>
Plays a system sound.
Parameters
soundType
Type of system sound to play. Values:
BOOT_UP (0)BACK_BUTTON (1)HOME_BUTTON (4)MENU_BUTTON (5)UP/DOWN/LEFT/RIGHT (6/9)MIC_ON/OFF (10/11)BLUETOOTH related (12/14)ERROR (15)VOLUME_UP/DOWN (16/17)- And others as defined in enum
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid sound type
- (-1): Sound file not found
- (-5): Server connection lost
registerAudioEventObserverAsync()
staticregisterAudioEventObserverAsync(callback:(value: any) => void):Promise<AudioStatus>
Registers a callback function for audio system events. Only one callback can be registered at a time system-wide.
Parameters
callback
(value: any) => void
Callback function receiving events:
- (0): Audio device connection changed
Parameters:
{device: AudioDevice, role: AudioRole, connect: boolean} - (1): Volume changed
Parameters:
{type: AudioVolumeType, volume: number} - (2): Global mute changed
Parameters:
{mute: boolean} - (3): Audio server unavailable
- (4): Audio server available
- (5): Usage state changed
Parameters:
{usage: AudioUsageType, active: boolean} - (6): Microphone mute changed
Parameters:
{muteState: boolean} - (7): Volume type mute changed
Parameters:
{volumeType: AudioVolumeType, muteState: boolean} - (8): Telephony mute changed Parameters: deviceType: AudioDevice, deviceAddress: string, deviceName: string, muteState: boolean
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid callback
- (-4): Callback already registered
- (-5): Server connection lost
Examples
/*
Creates a function and registers it in the Audio Event Observer to execute this
function whenever an audio change happens and stores returned AudioStatus
type in status after promise resolves
*\/
// Register for system-wide audio events
await AudioManager.registerAudioEventObserverAsync((event) => {
// Event object will contain different properties based on the event type
switch (event.audioEvent) {
case AudioEvent.DEVICE_STATE_UPDATE:
// Triggered when an audio device's connection state changes
// Parameters:
// - device: AudioDevice enum value
// - role: AudioRole enum value
// - connect: boolean indicating if device was connected (true) or disconnected (false)
console.log(`Device ${event.device} with role ${event.role} ${event.connect ? 'connected' : 'disconnected'}`);
break;
case AudioEvent.VOLUME_UPDATE:
// Triggered when volume changes for any audio type
// Parameters:
// - type: AudioVolumeType enum value
// - volume: number (0-100)
console.log('Volume changed for:', event.audioEvent, 'to:', event.volume);
break;
case AudioEvent.GLOBAL_VOLUME_MUTE_UPDATE:
// Triggered when global mute state changes
// Parameters:
// - mute: boolean indicating if system is muted
console.log('Global mute updated to state: ', event.mute);
break;
case AudioEvent.SERVER_DOWN:
// Triggered when audio server becomes unavailable
console.log('Audio server is down');
break;
case AudioEvent.SERVER_UP:
// Triggered when audio server becomes available
console.log('Audio server is up');
break;
case AudioEvent.AUDIO_USAGE_STATE_CHANGE:
// Triggered when audio usage state changes
// Parameters:
// - usage: AudioUsageType enum value
// - active: boolean indicating if usage became active
console.log('Usage: ', event.usage);
console.log('Active status: ', event.active);
break;
case AudioEvent.MIC_MUTE_STATE_UPDATE:
// Triggered when microphone mute state changes
// Parameters:
// - state: boolean indicating if mic is muted
console.log('Mic mute state changed: ', event.muteState);
break;
case AudioEvent.VOLUME_MUTE_UPDATE:
// Triggered when volume mute state changes for specific volume type
// Parameters:
// - volumeType: AudioVolumeType enum value
// - mute: boolean indicating if type is muted
console.log('Volume type: ', event.volumeType);
console.log('Mute state: ', event.muteState);
break;
case AudioEvent.TELEPHONY_MUTE_UPDATE:
// Triggered when telephony mute state changes
// Parameters:
// - deviceType: AudioDevice enum value
// - address: string representing device address
// - deviceName: string representing device name
// - mute: boolean indicating if telephony is muted
console.log('Telephony mute update!: ');
console.log('Device type: ', event.deviceType);
console.log('Device address: ', event.deviceAddress);
console.log('Device name: ', event.deviceName);
console.log('Device mute state: ', event.muteState);
break;
}
});
// Cleanup
await AudioManager.unregisterAudioEventObserverAsync();
setActiveVolumeAsync()
staticsetActiveVolumeAsync(volume:Int32):Promise<AudioStatus>
Sets the volume of the currently active stream. Active stream is determined by the most recent audio focus holder.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
volume
Int32
Volume level (0-100). Values outside this range will be clamped.
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid volume value
- (-9): Missing privilege
- (-8): No active stream
- (-5): Server connection lost
Examples
export const testSetActiveVolumeAsync = async (volume: number) => {
let requestStatus = await AudioManager.setActiveVolumeAsync(parseInt(volume));
if (requestStatus == 0) {
console.log("setActiveVolumeAsync SUCCESS");
} else {
console.log("setActiveVolumeAsync(): ERROR: " + requestStatus);
}
};
setGlobalVolumeMuteAsync()
staticsetGlobalVolumeMuteAsync(mute:boolean, flags?: AudioVolumeFlags):Promise<AudioStatus>
Sets the global volume mute state. When enabled, mutes all audio output regardless of individual volume settings.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
mute
boolean
true to enable global mute, false to disable
flags?
Optional flags affecting mute behavior:
- (0): No special behavior
- (1): Show mute state UI
- (2): Play state change sound
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-9): Missing privilege
- (-5): Server connection lost
- (-8): Operation failed
Examples
/*
Sets global mute to true and stores returned AudioStatus type in status after
promise resolves
*\/
const status = AudioManager.setGlobalVolumeMuteAsync(true).then((status) => {return status;}).catch((error) => console.log(error));
setMaxVolumeAsync()
staticsetMaxVolumeAsync(maxVolume:Int32):Promise<AudioStatus>
Sets the maximum volume limit for all audio types. This acts as a global volume ceiling that affects all volume types.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
maxVolume
Int32
Maximum volume level (0-100). Values outside this range will be clamped. Current volumes exceeding this limit will be reduced to match.
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid volume value
- (-9): Missing privilege
- (-5): Server connection lost
Examples
const testSetMaxVolume = async () => {
let volumeChangeStatus = await AudioManager.setMaxVolumeAsync(50);
if (volumeChangeStatus == 0) {
console.log("setMaxVolumeAsync() SUCCESS");
} else {
console.log("setMaxVolumeAsync(): ERROR: " + volumeChangeStatus);
}
};
setMicMuteAsync()
staticsetMicMuteAsync(mute:boolean):Promise<AudioStatus>
Sets the microphone mute state. This affects all audio recording from the microphone.
Parameters
mute
boolean
true to mute microphone, false to unmute
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-5): Server connection lost
- (-8): Operation failed
Examples
/*
Mutes microphone input and stores returned AudioStatus type in status after promise
resolves
*\/
const status = AudioManager.setMicMuteAsync(true).then((status) => {return status;}).catch((error) => console.log(error));
setMuteAsync()
staticsetMuteAsync(volType: AudioVolumeType, mute:boolean):Promise<AudioStatus>
Sets the system-wide mute state for a specific volume type. Muting a volume type silences all audio streams of that type.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
volType
Volume type to mute/unmute. See for types.
mute
boolean
true to mute, false to unmute
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid volume type
- (-9): Missing privilege
- (-5): Server connection lost
Examples
const testSetMuteAsync = async () => {
let updateStatus = await AudioManager.setMuteAsync(AudioVolumeType.VOLUME_TYPE_MEDIA, true);
if (updateStatus == 0) {
console.log("setMuteAsync() SUCCESS");
} else {
console.log("setMuteAsync(): ERROR: " + updateStatus);
}
};
setSinkFormatsSelectionPolicyAsync()
staticsetSinkFormatsSelectionPolicyAsync(policy: SinkFormatsSelectionPolicy):Promise<AudioStatus>
Sets the policy for selecting audio output formats on HDMI/digital outputs. This affects how audio is encoded when sent to supporting devices.
Parameters
policy
Format selection policy:
- (0): Choose based on sink capabilities
- (1): Force PCM output
- (2): Allow Dolby Digital Plus passthrough
- (3): Allow Dolby Digital passthrough
- (4): Force Dolby Digital Plus encoding
- (5): Force Dolby Digital encoding
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid policy
- (-8): Policy not supported
- (-5): Server connection lost
Examples
const testSetSinkFormatsSelectionPolicyAsync = async () => {
let sinkStatus = await AudioManager.setSinkFormatsSelectionPolicyAsync(SinkFormatsSelectionPolicy.AUTO);
if (sinkStatus == 0) {
console.log("setSinkFormatsSelectionPolicyAsync(): Result: SUCCESS")
} else {
console.log("setSinkFormatsSelectionPolicyAsync(): Result: ERROR: ", sinkStatus);
}
};
setSystemSoundThemeAsync()
staticsetSystemSoundThemeAsync(soundTheme:String):Promise<AudioStatus>
Sets the active system sound theme. The theme must be one of those returned by .
Parameters
soundTheme
String
Theme identifier string
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid theme
- (-1): Theme files not found
- (-5): Server connection lost
setTelephonyMuteAsync()
staticsetTelephonyMuteAsync(device: AudioDevice, address:String, mute:boolean):Promise<AudioStatus>
Sets the mute state for telephony audio on a specific device.
Parameters
device
Device to set mute state for
address
String
Unique identifier for the device.
mute
boolean
true to mute, false to unmute
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invanvalid parameters
- (-8): Device not in telephony mode
- (-5): Server connection lost
Examples
let muteStatus = await AudioManager.setTelephonyMuteAsync(AudioDevice.DEVICE_TELEPHONY, "0X859978AF", true);
if (muteStatus == 0) {
console.log("setTelephonyMuteAsync(): Result: SUCCESS")
status = status + "setTelephonyMuteAsync():\nResult: SUCCESS\n";
} else {
console.log("setTelephonyMuteAsync(): Result: ERROR: ", muteStatus);
status = status + "setTelephonyMuteAsync():\nResult: ERROR: " + muteStatus.toString() + "\n";
}
setVolumeAsync()
staticsetVolumeAsync(type: AudioVolumeType, volume:Int32, flags?: AudioVolumeFlags):Promise<AudioStatus>
Sets system-wide volume for a specific audio type.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
type
The audio type to adjust:
- (-1)
- (0)
- (1)
- (2)
- (3)
- (4)
- (5)
- (6)
- (7)
- (8)
volume
Int32
Volume level (0-100). Values outside this range will be clamped.
flags?
Optional flags affecting volume change behavior:
- (0): No special behavior
- (1): Show volume slider UI
- (2): Play volume change sound
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid type or volume
- (-9): Missing privilege
- (-5): Server connection lost
Examples
/*
Sets volume of audio type alarm to 50% and stores returned AudioStatus type in
status after the promise resolves, otherwise stores undefined and prints an error
if promise fails
*\/
const status = AudioManager.setVolumeAsync(AudioVolumeType.VOLUME_TYPE_ALARM, 50)
.then((status) => {return status;}).catch((error) => console.log(error));
startTelephonyAsync()
staticstartTelephonyAsync(device: AudioDevice, address:String, mode: AudioTelephonyMode):Promise<AudioStatus>
Start telephony call from the specified device
Client can simply specify the device DEVICE_DEFAULT to let the audio server determine the telephony and initiate the call. On some specific platforms, it is possible to support multiple telephony sources such as HFP device, a voice call modem etc. In such case, the client can actually query the list of devices using the API and select a specific device and corresponding address.
Parameters
device
Device to use for telephony audio. Common values:
- (1 30)
- (1 2)
- (1 18)
- (1 1)
address
String
Unique identifier for the device (e.g., Bluetooth address)
mode
Telephony audio mode:
MODE_NARROW_BAND (0): Standard voice qualityMODE_WIDE_BAND (1): HD voice quality
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid parameters
- (-8): Device not available
- (-5): Server connection lost
stopTelephonyAsync()
staticstopTelephonyAsync(device: AudioDevice, address:String):Promise<AudioStatus>
Stops telephony audio on the specified device. Must be called when a call ends or when telephony audio is no longer needed.
Parameters
device
Device to stop telephony audio on
address
String
Unique identifier for the device (e.g., Bluetooth address)
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid parameters
- (-8): Telephony not active
- (-5): Server connection lost
unregisterAudioEventObserverAsync()
staticunregisterAudioEventObserverAsync():Promise<AudioStatus>
Unregister the previously registered audio event callback.
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-8): No callback registered
- (-5): Server connection lost
Examples
/*
Unregisters callback function and stores returned AudioStatus type in status after
promise resolves
*\/
const status = AudioManager.unregisterAudioEventObserverAsync().then((status) => {return status;}).catch((error) => console.log(error));
updateActiveVolumeAsync()
staticupdateActiveVolumeAsync(update:Int32, fallbackType: AudioVolumeType):Promise<AudioStatus>
Updates the volume of the active stream by incrementing or decrementing. If no stream is active, adjusts the system-wide volume of the specified fallback type.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
update
Int32
Type of update:
- (0): Increase volume by one step
- (1): Decrease volume by one step
fallbackType
Volume type to adjust if no active stream
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid parameters
- (-9): Missing privilege
- (-5): Server connection lost
Examples
const testUpdateActiveVolumeAsync = async () => {
let updateStatus = await AudioManager.updateActiveVolumeAsync(0, AudioVolumeType.VOLUME_TYPE_MEDIA);
if (updateStatus == 0) {
console.log("updateActiveVolumeAsync() SUCCESS");
} else {
console.log("updateActiveVolumeAsync(): ERROR: " + updateStatus);
}
};
updateVolumeAsync()
staticupdateVolumeAsync(type: AudioVolumeType, volume:Int32):Promise<AudioStatus>
Updates the system-wide volume of a specific audio type by incrementing or decrementing.
Requires privilege: com.amazon.audio.privilege.settings.control
This API is restricted to Kepler system applications, and is not available to other apps. Invoking this api without the right privilege may result in no-op or a security exception.
Parameters
type
The audio type to adjust. See for types.
volume
Int32
Type of update:
- (0): Increase volume by one step
- (1): Decrease volume by one step
Returns
Promise<AudioStatus>
Promise A promise that resolves to:
- (0): Success
- (-2): Invalid parameters
- (-9): Missing privilege
- (-5): Server connection lost
Examples
const testUpdateVolumeAsync = async () => {
let updateStatus = await AudioManager.updateVolumeAsync(AudioVolumeType.VOLUME_TYPE_MEDIA, 0);
if (updateStatus == 0) {
console.log("updateVolumeAsync() SUCCESS");
} else {
console.log("updateVolumeAsync(): ERROR: " + updateStatus);
}
};
Last updated: Jul 22, 2026

