string
Device name.
Type of the device.
string
The user-friendly name (e.g. "USB Microphone").
string
The unique identifier of the audio device.
boolean
True if this is the current active device.
number
The sound level of the device, volume for output, gain for input.
string optional
The stable/persisted device id string when available.
Stream type associated with this device.
boolean optional
If set, only audio devices whose active state matches this value will satisfy the filter.
StreamType[] optional
If set, only audio devices whose stream type is included in this list will satisfy the filter.
string[] optional
List of input devices specified by their ID.
To indicate input devices should be unaffected, leave this property unset.
string[] optional
List of output devices specified by their ID.
To indicate output devices should be unaffected, leave this property unset.
number optional
The audio device's desired sound level. Defaults to the device's current sound level.
If used with audio input device, represents audio device gain.
If used with audio output device, represents audio device volume.
Available audio device types.
"HEADPHONE" "MIC" "USB" "BLUETOOTH" "HDMI" "INTERNAL_SPEAKER" "INTERNAL_MIC" "FRONT_MIC" "REAR_MIC" "KEYBOARD_MIC" "HOTWORD" "LINEOUT" "POST_MIX_LOOPBACK" "POST_DSP_LOOPBACK" "ALSA_LOOPBACK" "OTHER"
string
ID of device whose sound level has changed.
number
The device's new sound level.
boolean
Whether or not the stream is now muted.
The type of the stream for which the mute value changed. The updated mute value applies to all devices with this stream type.
Type of stream an audio device provides.
"INPUT" "OUTPUT"
chrome.audio.getDevices(
filter?: DeviceFilter,
callback?: function,
)
Gets a list of audio devices filtered based on filter
.
DeviceFilter optional
Device properties by which to filter the list of returned audio devices. If the filter is not set or set to {}
, returned device list will contain all available audio devices.
function optional
The callback
parameter looks like: (devices: AudioDeviceInfo[]) => void
Promise<AudioDeviceInfo[]>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.audio.getMute(
streamType: StreamType,
callback?: function,
)
Gets the system-wide mute state for the specified stream type.
Stream type for which mute state should be fetched.
function optional
The callback
parameter looks like: (value: boolean) => void
boolean
Promise<boolean>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.audio.setActiveDevices(
ids: DeviceIdLists,
callback?: function,
)
Sets lists of active input and/or output devices.
Specifies IDs of devices that should be active. If either the input or output list is not set, devices in that category are unaffected.
It is an error to pass in a non-existent device ID.
function optional
The callback
parameter looks like: () => void
Promise<void>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.audio.setMute(
streamType: StreamType,
isMuted: boolean,
callback?: function,
)
Sets mute state for a stream type. The mute state will apply to all audio devices with the specified audio stream type.
Stream type for which mute state should be set.
boolean
New mute value.
function optional
The callback
parameter looks like: () => void
Promise<void>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.audio.setProperties(
id: string,
properties: DeviceProperties,
callback?: function,
)
Sets the properties for the input or output device.
string
function optional
The callback
parameter looks like: () => void
Promise<void>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
chrome.audio.onDeviceListChanged.addListener(
callback: function,
)
Fired when audio devices change, either new devices being added, or existing devices being removed.
function
The callback
parameter looks like: (devices: AudioDeviceInfo[]) => void
chrome.audio.onLevelChanged.addListener(
callback: function,
)
Fired when sound level changes for an active audio device.
function
The callback
parameter looks like: (event: LevelChangedEvent) => void
chrome.audio.onMuteChanged.addListener(
callback: function,
)
Fired when the mute state of the audio input or output changes. Note that mute state is system-wide and the new value applies to every audio device with specified stream type.
function
The callback
parameter looks like: (event: MuteChangedEvent) => void
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-05-24 UTC.