Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
rollbak
Posts: 2
Registered: ‎11-19-2009
My Device: Not Specified

Get Device current Master Volume

Hello,

 

I need to get the current master volume on the device from my application. I tried with 3 methods but only one works, but the problem is that i need to make this work in all posible firmwares.

 

  net.rim.device.api.system.Alert.getVolume();  //Doesn't work, always returns 100.
  net.rim.device.api.system.Audio.getVolume(); //Doesn't work, always returns 100.
  net.rim.device.api.notification.NotificationsManager.getMasterNotificationVolume();   //Works but it is only present in 4.7.0 and above.

 

So i want to know if there is another way of gettting that info programatically for firmware previous to 4.7.0.

 

Thanks,

 

Lucas

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Get Device current Master Volume

Assuming that you are using the Player/Manager interface to control the playback, you get a VolumeControl object from the Player:

 

Somthing along these lines:

 

    m_player = Manager.createPlayer(input,"audio/mpeg");
    m_player.realize();
    VolumeControl volumeControl = getVolumeControl(m_player);
    if (volumeControl != null)
       volumeControl.setLevel(m_volume);
    m_player.prefetch();
    m_player.start();

 

Please use plain text.
New Developer
rollbak
Posts: 2
Registered: ‎11-19-2009
My Device: Not Specified

Re: Get Device current Master Volume

This is the oposite of what i want. I just want to get the device master volume level, not set a volume level to a player.

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Get Device current Master Volume

There is a getLevel() also, but I understand your point.

 

AFAIK this master volume didn't come into the API until recently.

Please use plain text.