If you want to play sound with Alert:
class Scr extends MainScreen implements FieldChangeListener {
ButtonField mVolumeUp;
ButtonField mVolumeDown;
ButtonField mPlay;
LabelField mVolumeLabel;
int mVolumeValue = 50;
private static final short[] tune = new short[] { 466, 125, 10, 466 };
public Scr() {
mVolumeLabel = new LabelField("Volume: " + mVolumeValue);
add(mVolumeLabel);
mVolumeUp = new ButtonField("Vol Up", ButtonField.CONSUME_CLICK);
mVolumeUp.setChangeListener(this);
add(mVolumeUp);
mVolumeDown = new ButtonField("Vol Down", ButtonField.CONSUME_CLICK);
mVolumeDown.setChangeListener(this);
add(mVolumeDown);
mPlay = new ButtonField("Play", ButtonField.CONSUME_CLICK);
mPlay.setChangeListener(this);
add(mPlay);
}
public void fieldChanged(Field field, int context) {
if (mVolumeUp == field) {
if (mVolumeValue <= 90)
mVolumeValue += 10;
mVolumeLabel.setText("Volume: " + mVolumeValue);
} else if (mVolumeDown == field) {
if (mVolumeValue >= 10)
mVolumeValue -= 10;
mVolumeLabel.setText("Volume: " + mVolumeValue);
} else if (mPlay == field) {
Alert.startAudio(tune, mVolumeValue);
}
}
}
Tested on RIM 4.5 8310 simulator