Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to get external volume buttons events

From Wiki
Jump to: navigation, search
Article Metadata
Created: prakash.raman (08 Jun 2009)
Last edited: hamishwillee (30 Jul 2013)

External volume buttons

From S60 3rd Edition FP 2 onwards, external volume buttons can be used to change the volume level of MMAPI players in mobile devices that have the volume buttons present.

The buttons work in this way when a MIDlet that uses MMAPI is on foreground. They change the volume level for MMAPI Players globally, that is, the volume level of every Player in every MIDlet is altered.

A Nokia proprietary event is used to notify the MIDlet when volume is changed with External volume keys. The notification is made via PlayerListener.playerUpdate(Evendata) callback with the event

Code Sample

The event can be decoded to know the current global volume level as shown below:

// Effective volume considering both midlet volume and global volume
int actualVolume = 0;
int globalVolume = 0;
public void playerUpdate(Player p, String event, Object eventData) {
// get the current midlet volume level
int midletVolume = vc.getLevel();
if(event.equals("")) {
// get the current global volume level
globalVolume = Integer.parseInt(eventData.toString());
// This event is generated when midlet volume level is changed
if(event.equals("volumeChanged")) {
midletVolume = vc.getLevel();
actualVolume = (globalVolume/100) * midletVolume;


This page was last modified on 30 July 2013, at 03:51.
44 page views in the last 30 days.