com.nokia.mid.media
Interface AudioOutputControl


public interface AudioOutputControl

AudioOutputControl is an interface for setting application preferred audio output mode.

SYMBIAN SPECIFIC BEHAVIOR:

Audio output mode is within the scope of a player instance and can be set when the MIDlet which set the audio routing is finished with the audio when the player is in REALIZED, PREFETCHED, STARTED or STOPPED state. The preferences are applied or imposed when media is played.

Audio output control is retrieved using 'Player' interface by calling Control getControl ( java.lang.string controlType ) The control type to be passed as an argument is com.nokia.mid.media.AudioOutputControl

S40 SPECIFIC BEHAVIOR:

The AudioOutputControl is a Global Control and will effect all players. When the MIDlet which set the audio routing is finished with the audio change then it must set it back to DEFAULT.

Audio output control is retrieved using 'GlobalManager' interface by calling Control getControl ( java.lang.string controlType ) The control type to be passed as an argument is com.nokia.mid.media.AudioOutputControl

Code Snippet:

1. Getting AudioOutputControl:

In SYMBIAN:

Player p = Manager.createPlayer(getClass().getResourceAsStream ("nokia_tune.mid"), "audio/midi");
p.realize();
AudioOutputControl iAudioOutputControl= (AudioOutputControl)p.getControl("com.nokia.mid.media.AudioOutputControl");
p.addPlayerListener(this);


In S40:

import javax.microedition.amms.*;
iAudioOutputControl = (AudioOutputControl) GlobalManager.getControl("com.nokia.mid.media.AudioOutputControl");


2. Setting and getting Audio Output Mode:

2.1 Setting PRIVATE mode:

iAudioOutputControl.setOutputMode(PRIVATE);

2.2 Getting Current Mode:

AudioOutput audioOutput = iAudioOutputControl.getCurrent();
int mode = audioOutput.getOutputMode();

3. Getting notification:

Notifications are supported only on SYMBIAN.
The notification about the preference change is done using PlayerListener's playerUpdate() function. Whereas, this specific Event type is "com.nokia.audiooutputchange.event" and Event data is AudioOutput object.

public void playerUpdate(Player aPlayer, String aEvent, Object aEventData){

if(aEvent.equals("com.nokia.audiooutputchange.event")){
helloForm.append("com.nokia.audiooutputchange.event");
// get the mode
Int mode = ((AudioOutput)aEventData).getActiveOutputMode();
}

}

Since:
1.4


Field Summary
static int ALL
          The ALL audio output mode.
static int DEFAULT
          The DEFAULT audio output mode.
static int NONE
          The NONE audio output mode.
static int PRIVATE
          The PRIVATE audio output mode.
static int PUBLIC
          The PUBLIC audio output mode.
 
Method Summary
 int[] getAvailableOutputModes()
          Get all supported audio output modes
 AudioOutput getCurrent()
           
 int getOutputMode()
          Get the currently set audio output mode.
 int setOutputMode(int mode)
          Sets the preferred audio output mode.
 

Field Detail

DEFAULT

static final int DEFAULT
The DEFAULT audio output mode.

No Preference. The audio routing is restored to the default value.

Value 0 is assigned to DEFAULT.

SYMBIAN SPECIFIC BEHAVIOR:
Audio is by default routed to loudspeaker. Audio output changes dynamically to headset, when headset is connected to the device and vice versa. Application is notified about audio output change with audio output change event.

See Also:
Constant Field Values

ALL

static final int ALL
The ALL audio output mode.

Audio is routed to one public and one private output at the same time. The primary output method within public and private outputs is selected by the device and can change dynamically when external peripherals are connected or disconnected by the user (see "public" and "private" for their priorities).

Value 1 is assigned to ALL.

See Also:
Constant Field Values

NONE

static final int NONE
The NONE audio output mode.

Audio is not routed to any output.

Value 2 is assigned to NONE.

See Also:
Constant Field Values

PRIVATE

static final int PRIVATE
The PRIVATE audio output mode.

Audio is routed to earpiece or wired / wireless(BT) headset if connected. If there are several private output methods available at the same time audio is routed to only one of those selected with following priority order 1) wired headset 2) wireless headset 3) earpiece.

Value 3 is assigned to PRIVATE.

See Also:
Constant Field Values

PUBLIC

static final int PUBLIC
The PUBLIC audio output mode.

Audio is routed to loudspeaker, wireless(BT) speakers or TV output. If there are several public output methods available at the same time audio is routed to only one of those selected with following priority order: (1) wired headset 2) Loudspeaker

Value 4 is assigned to PUBLIC.

See Also:
Constant Field Values
Method Detail

getAvailableOutputModes

int[] getAvailableOutputModes()
Get all supported audio output modes

Returns:
The currently supported output modes


getOutputMode

int getOutputMode()
Get the currently set audio output mode. This is the last audioOutputMode sent to setOutputMode or DEFAULT if none has been set.

This does not return the actual audio output mode of the device. The AudioOutput can be used to provide the actual audio output mode.

Returns:
The last audio output mode which was sent to setOutputMode.

getCurrent

AudioOutput getCurrent()
Returns:
AudioOutput object.

setOutputMode

int setOutputMode(int mode)
Sets the preferred audio output mode.

Returns:
audio output mode set or -1 if unable to set
Throws:
java.lang.IllegalArgumentException - with message "audio output mode is not valid" when the audio output mode is not valid
java.lang.IllegalStateException - with message "Accessory connected" if unable to change the audio routing due to an accessory connected
java.lang.SecurityException - with message "Permission denied" if the called does not have permission to set the audio routing.

SYMBIAN SPECIFIC BEHAVIOR:
This effects only a specific player instance. Preference can be set when Player is in REALIZED, PREFETCHED, STARTED or STOPPED state.

S40 SPECIFIC BEHAVIOR:
This will effect all players.


forum.nokia.com/java

Copyright (c) 2002-2010 Nokia Corporation. All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc.