This API is experimental. It is only available to Chrome users on the dev channel.

chrome.audio

Description: The chrome.audio API is provided to allow users to get information about and control the audio devices attached to the system. This API is currently only implemented for ChromeOS.
Availability: Dev channel only.
Permissions: "audio"

Summary

Methods
getInfo chrome.audio.getInfo(function callback)
setActiveDevices chrome.audio.setActiveDevices(array of string ids, function callback)
setProperties chrome.audio.setProperties(string id, object properties, function callback)
Events
onDeviceChanged

Methods

getInfo

chrome.audio.getInfo(function callback)

Get the information of all audio output and input devices.

Parameters
function callback

The callback parameter should be a function that looks like this:

function(array of object outputInfo, array of object inputInfo) {...};
array of object outputInfo

Properties of each object

string id The unique identifier of the audio output device.
string name The user-friendly name (e.g. "Bose Amplifier").
boolean isActive True if this is the current active device.
boolean isMuted True if this is muted.
double volume The output volume ranging from 0.0 to 1.0.
array of object inputInfo

Properties of each object

string id The unique identifier of the audio input device.
string name The user-friendly name (e.g. "USB Microphone").
boolean isActive True if this is the current active device.
boolean isMuted True if this is muted.
double gain The input gain ranging from 0.0 to 1.0.

setActiveDevices

chrome.audio.setActiveDevices(array of string ids, function callback)

Select a subset of audio devices as active.

Parameters
array of string ids
function callback

The callback parameter should be a function that looks like this:

function() {...};

setProperties

chrome.audio.setProperties(string id, object properties, function callback)

Sets the properties for the input or output device.

Parameters
string id
object properties
boolean isMuted True if this is muted.
double (optional) volume If this is an output device then this field indicates the output volume. If this is an input device then this field is ignored.
double (optional) gain If this is an input device then this field indicates the input gain. If this is an output device then this field is ignored.
function callback

The callback parameter should be a function that looks like this:

function() {...};

Events

onDeviceChanged

Fired when anything changes to the audio device configuration.

addListener

chrome.audio.onDeviceChanged.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function() {...};