Packageflash.media
Classpublic final class AudioDeviceManager
InheritanceAudioDeviceManager Inheritance EventDispatcher Inheritance Object

Language version: ActionScript 3.0
Runtime version: AIR 28

Use the AudioDeviceManager class to get audio device information of the system, and select a device for audio playback. User can change audio output device either through Flash Player's Settings UI, or the AudioDeviceManager API. Both of them are in sync with audio output settings. AudioDeviceManager API was enabled for Flash Player 27. It is now enabled for AIR Desktop from AIR 28.

The audio device selected from one AIR application does not affect the audio from other AIR applications or Flash Player instances.

Privacy Restriction

AudioDeviceManager API is under User Invoked Action (UIA) restriction, that is, it can only be invoked with some user interaction. If this API is not invoked by user interaction, Flash Player throws runtime error IllegalOperationError with error code set to 2176. In case of AIR applications, the UIA check will be applied when we load an external SWF/HTML hosted over a network. If the externally loaded SWF/HTML tries to change the audio output device without any user invoked action, then AIR runtime throws an error IllegalOperationError with error code 2176.

Access AudioDeviceManager instance

AudioDeviceManager instance is a singleton object, it is in sync with Flash Player's Audio Output Settings. Client should use AudioDeviceManager.audioDeviceManager to get a reference to this singleton object.

Get the current audio devices available on the system

Use AudioDeviceManager.deviceNames to get all the available audio output devices in the system.

Get the current selected audio device

Use AudioDeviceManager.selectedDeviceIndex to find the index of the current used audio output device. Use this index to find the device name the device list returned from AudioDeviceManager.deviceNames

Select an audio output device

Set AudioDeviceManager.selectedDeviceIndex to a different value can make that device to be the current selected audio playback device.

Monitor audio output device change

Audio output device may change because of user selecting a different device from Flash Player's Settings UI, Content setting AudioDeviceManager.selectedDeviceIndex, audio device being added/removed from the system. Client application can register listener to event: AudioOutputChangeEvent.AUDIO_OUTPUT_CHANGE to receive notification when audio output device change happens. The reason property of the event object indicates how this change is triggered. There are 2 possible values for reason property: AudioOutputChangeReason.USER_SELECTION indicates that user selects a different audio output device through Flash Player's Settings UI, or Content sets AudioDeviceManager.selectedDeviceIndex. AudioOutputChangeReason.DEVICE_CHANGE indicates that audio output device has been added or removed from the system.



Public Properties
 PropertyDefined by
  audioDeviceManager : AudioDeviceManager
[static][read-only] The singleton instance of the AudioDeviceManager object.
AudioDeviceManager
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  deviceNames : Array
[read-only] An array of strings containing the names of all available audio output devices.
AudioDeviceManager
  isSupported : Boolean
[static][read-only] Whether AudioDeviceManager is enabled.
AudioDeviceManager
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  selectedDeviceIndex : int
The index of the current selected audio output device, as reflected in the array returned by AudioDeviceManager.deviceNames.
AudioDeviceManager
Public Methods
 MethodDefined by
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 EventSummaryDefined by
 Inherited [broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
   Dispatched when audio output device is changed for the following reasons: (1) User selection - User selects through Flash Player Settings UI Content setting AudioDeviceManager.selectedDeviceIndex (2) Device change - Audio device is added/removed from the system.AudioDeviceManager
 Inherited [broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
Property detail
audioDeviceManagerproperty
audioDeviceManager:AudioDeviceManager  [read-only]

The singleton instance of the AudioDeviceManager object.

Implementation
    public static function get audioDeviceManager():AudioDeviceManager
deviceNamesproperty 
deviceNames:Array  [read-only]

An array of strings containing the names of all available audio output devices. This array provides the zero-based index of each audio output device and the number of audio output devices on the system, through the following property: AudioDeviceManager.deviceNames.length For more information, see the Array class entry. This list of device names is the same as that in Audio Output Settings.

Note for Chrome browser: Chrome requires user to grant Microphone access permission in order to enumerate audio output devices, because Audio Output and Audio Input share the same permission, and only Audio Input permission warning will be displayed to the user.

Implementation
    public function get deviceNames():Array
isSupportedproperty 
isSupported:Boolean  [read-only]

Whether AudioDeviceManager is enabled.

Implementation
    public static function get isSupported():Boolean
selectedDeviceIndexproperty 
selectedDeviceIndex:int  [read-write]

The index of the current selected audio output device, as reflected in the array returned by AudioDeviceManager.deviceNames. This index in sync with Audio Output Settings.

Implementation
    public function get selectedDeviceIndex():int
    public function set selectedDeviceIndex(value:int):void
Event detail
audioOutputChangeevent 
Event object type: flash.events.AudioOutputChangeEvent

Language version: ActionScript 3.0
Runtime version: AIR 28

Dispatched when audio output device is changed for the following reasons: (1) User selection - User selects through Flash Player Settings UI Content setting AudioDeviceManager.selectedDeviceIndex (2) Device change - Audio device is added/removed from the system.

Check the reason property of this event to find out what causes the change. The possible reasons are: AudioOutputChangeReason.USER_SELECTION AudioOutputChangeReason.DEVICE_CHANGE.