Volume in a MIDlet can be set via the VolumeControl
interface. Once you have created and realized the player, get the VolumeControl
interface of the player by calling the getControl()
method and set the desired volume level in
a range from 0 to 100 with the setLevel()
method
of VolumeControl
// Get the player whose volume level should be changed... Player player = ...;
// Get the VolumeControl of Player VolumeControl control = (VolumeControl) player.getControl("VolumeControl"); if (control!=null) { // Set new volume level to 50% of maximum control.setLevel(50); }
From S60 3rd Edition Feature Pack 2 and Series 40 5th Edition Feature Pack 1 onwards, devices have their own volume keys for controlling the volume level.
For more information and an example MIDlet, see article MIDlet volume control in Series 40 and S60 devices in the Nokia Developer Wiki.