Dart Documentationchrome.audioChromeAudio

ChromeAudio class

class ChromeAudio extends ChromeApi {
 static final JsObject _audio = chrome['audio'];

 ChromeAudio._();

 bool get available => _audio != null;

 /**
  * Get the information of all audio output and input devices.
  * 
  * Returns:
  * [outputInfo] null
  * [inputInfo] null
  */
 Future<GetInfoResult> getInfo() {
   if (_audio == null) _throwNotAvailable();

   var completer = new ChromeCompleter<GetInfoResult>.twoArgs(GetInfoResult._create);
   _audio.callMethod('getInfo', [completer.callback]);
   return completer.future;
 }

 /**
  * Select a subset of audio devices as active.
  */
 Future setActiveDevices(List<String> ids) {
   if (_audio == null) _throwNotAvailable();

   var completer = new ChromeCompleter.noArgs();
   _audio.callMethod('setActiveDevices', [jsify(ids), completer.callback]);
   return completer.future;
 }

 /**
  * Sets the properties for the input or output device.
  */
 Future setProperties(String id, DeviceProperties properties) {
   if (_audio == null) _throwNotAvailable();

   var completer = new ChromeCompleter.noArgs();
   _audio.callMethod('setProperties', [id, jsify(properties), completer.callback]);
   return completer.future;
 }

 Stream get onDeviceChanged => _onDeviceChanged.stream;

 final ChromeStreamController _onDeviceChanged =
     new ChromeStreamController.noArgs(_audio, 'onDeviceChanged');

 void _throwNotAvailable() {
   throw new UnsupportedError("'chrome.audio' is not available");
 }
}

Extends

ChromeApi > ChromeAudio

Properties

final bool available #

Returns true if the API is available. The common causes of an API not being avilable are:

  • a permission is missing in the application's manifest.json file
  • the API is defined on a newer version of Chrome then the current runtime
docs inherited from ChromeApi
bool get available => _audio != null;

final Stream onDeviceChanged #

Stream get onDeviceChanged => _onDeviceChanged.stream;

Methods

Future<GetInfoResult> getInfo() #

Get the information of all audio output and input devices.

Returns: outputInfo null inputInfo null

Future<GetInfoResult> getInfo() {
 if (_audio == null) _throwNotAvailable();

 var completer = new ChromeCompleter<GetInfoResult>.twoArgs(GetInfoResult._create);
 _audio.callMethod('getInfo', [completer.callback]);
 return completer.future;
}

Future setActiveDevices(List<String> ids) #

Select a subset of audio devices as active.

Future setActiveDevices(List<String> ids) {
 if (_audio == null) _throwNotAvailable();

 var completer = new ChromeCompleter.noArgs();
 _audio.callMethod('setActiveDevices', [jsify(ids), completer.callback]);
 return completer.future;
}

Future setProperties(String id, DeviceProperties properties) #

Sets the properties for the input or output device.

Future setProperties(String id, DeviceProperties properties) {
 if (_audio == null) _throwNotAvailable();

 var completer = new ChromeCompleter.noArgs();
 _audio.callMethod('setProperties', [id, jsify(properties), completer.callback]);
 return completer.future;
}