Device Speaker Control (Mobile)

Mobile devices generally have two separate hardware mechanisms for the transmission of audio. One of these is the speaker used in the transmission of voice data — primarily used for activities like phone calls. The other is a much fuller speaker, used for most any other activity: games, applications, music and video playback, et cetera.

Depending upon the needs of a particular application, AIR developers now have the ability to target a particular hardware speaker on the device. This is accessed by setting the audioPlaybackMode property of the flash.media.SoundMixer class to either the AudioPlaybackMode.MEDIA or AudioPlaybackMode.VOICE constants set through the flash.media.AudioPlaybackMode class.

Note

Another interesting addition is the ability to override the default voice behavior through use of the SoundMixer.useSpeakerphoneForVoice Boolean property.

package {
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.media.AudioPlaybackMode; import flash.media.Sound; import flash.media.SoundMixer; import flash.net.URLRequest; import flash.text.TextField; import flash.text.TextFormat; [SWF(backgroundColor="#000000")] public class SoundSpeaker extends Sprite { private var traceField:TextField; private var sound:Sound; private var id3:Boolean; public function SoundSpeaker() { super(); stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; generateDisplayObjects(); ...

Get What's New in Adobe AIR 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.