Package | flash.media |
Class | public final class AudioDeviceManager |
Inheritance | AudioDeviceManager EventDispatcher Object |
Language version: | ActionScript 3.0 |
Runtime version: | 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.
Property | Defined by | ||
---|---|---|---|
audioDeviceManager : AudioDeviceManager
[static][read-only]
The singleton instance of the AudioDeviceManager object.
| AudioDeviceManager | ||
constructor : 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 | ||
prototype : 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 |
Event | Summary | Defined by | ||
---|---|---|---|---|
[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 | |||
[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive. | EventDispatcher |
audioDeviceManager | property |
audioDeviceManager:AudioDeviceManager
[read-only]The singleton instance of the AudioDeviceManager object.
Implementation public static function get audioDeviceManager():AudioDeviceManager
deviceNames | property |
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
isSupported | property |
isSupported:Boolean
[read-only]Whether AudioDeviceManager is enabled.
Implementation public static function get isSupported():Boolean
selectedDeviceIndex | property |
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.
public function get selectedDeviceIndex():int
public function set selectedDeviceIndex(value:int):void
audioOutputChange | event |
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
.