Documentation: Chrome Audio API
A promise-based wrapper for the Chrome audio API.
- isAvailableAudio()
- getAudioDevices(filter?)
- getAudioMute(streamType)
- setAudioActiveDevices(ids?)
- setAudioMute(streamType, isMuted)
- setAudioProperties(id, properties?)
isAvailableAudio(method?: ApiMethodName<typeof chrome.audio>): booleanThe optional method is a native function name, for example isAvailableAudio("getDevices").
Import the public ApiMethodName type from @addon-core/browser for your own typed helpers.
This checks callable presence without invoking the method; permissions and argument support still require handling.
Returns true when the audio namespace is present on the API selected by browser() in the current context.
Returns false if the namespace or WebExtension environment is absent, or if accessing it throws.
The check is synchronous, does not log, and reads the current API on every call without caching.
Without an argument, it checks namespace presence only. Pass a native method name to also check that it is callable.
Neither form verifies permissions, argument support, or a successful operation. See method availability.
import {isAvailableAudio} from "@addon-core/browser";
if (isAvailableAudio()) {
// The namespace is present; handle operation-specific failures when using it.
}getAudioDevices(filter?: chrome.audio.DeviceFilter): Promise<chrome.audio.AudioDeviceInfo[]>
Retrieves the list of available audio devices, optionally filtered.
getAudioMute(streamType: chrome.audio.StreamType): Promise<boolean>
Retrieves the system-wide mute state of the specified audio stream type.
setAudioActiveDevices(ids?: chrome.audio.DeviceIdLists): Promise<void>
Sets the lists of active input and/or output devices.
setAudioMute(streamType: chrome.audio.StreamType, isMuted: boolean): Promise<void>
Sets the mute state for the specified audio stream type.
setAudioProperties(id: string, properties?: chrome.audio.DeviceProperties): Promise<void>
Updates properties for the specified audio device.
onAudioDeviceListChanged(
callback: (devices: chrome.audio.AudioDeviceInfo[]) => void
): () => void
Adds a listener that fires when audio devices are added or removed. Returns an unsubscribe function.
onAudioLevelChanged(
callback: (event: chrome.audio.LevelChangedEvent) => void
): () => void
Adds a listener that fires when sound level changes for an active audio device. Returns an unsubscribe function.
onAudioMuteChanged(
callback: (event: chrome.audio.MuteChangedEvent) => void
): () => void
Adds a listener that fires when the mute state of the audio input or output changes. Returns an unsubscribe function.