views:

1799

answers:

4

My current code is this:

int volume = Alert.getVolume(); // reads 100 Alert.setVolume(0);

It DOESN'T change the volume setting, like it would be supposed to do :( Even calling Alert.mute(true) doesn't produce any good effect. Audio.setVolume(0) also doesn't work!

I'm running this on a Curve 8310. I have another software installed though that successfully manages to lower the volume setting a lot...so I suppose I'm doing something wrong. Any idea?

A: 

Certain functions on the blackberry (but not the emulator) only work with signed code. I'm not sure if it is the case for volume, but I wouldn't be surprised when it was.

Paul de Vrieze
You'd see a problem during the build/deployment if there were signed apis being called without the COD being appropriately signed.
Ken Gentle
You can also force the emulator/JDE to fail or emit warnings if unsigned APIs are in use.
Ken Gentle
+1  A: 

If you're using the class javax.microedition.lcdui.Alert, that may be your problem. Try taking a look at the net.rim.device.api.notification.NotificationsManager class and its other package classes/interfaces.

Though the simple/polite way is just to ask the user to change the user profiles manually. If I set my blackberry to silent and some application makes a crazy noise (or doesn't make a noise at all if I'm expecting an important call), I'll be removing that application asap.

A: 

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

Max Gontar
A: 

hi.. can anyone help me in this. plz. i need source code of blackberry java application with play/pause and volume slider control and to play the live mp3 streaming audio..

Thanks in advance. :)

Karthik

karthik raja