views:

520

answers:

1

Currently, I have some basic code to play a simple tone whenever a button is pressed in the command item menu.

Using: Manager.playTone(note, duration, volume);

I also have a blackberry that I'm testing this same midlet on and the sound works fine. So, is this something specific to Nokia phones that aren't allowing me to play the sound?

I've made sure to build it using the correct CLDC and MIDP versions.

I've also tried the audio demos that are in the Netbeans IDE, and still no luck. It throws a "cannot create player" message.

+1  A: 

http://discussion.forum.nokia.com/forum/showthread.php?t=91500

This thread on Forum Nokia seems to suggest that certain Nokia models have problems playing tones with the Manager.playTone() function, more specifically a MediaException is thrown, as you are having (MediaException is just the default exception if any problem occurs when trying to play a tone).

You can try sleeping the thread after calling Manager.playTone for greater than the length of the tone. There is a possibility that you get into a state where you are trying to play two or more tones at once and the phone might not allow more than one player to be created at a time.

If all else fails you can use the Nokia UI Sound class (com.nokia.mid.sound.Sound) to play the tone. It is deprecated and replaced with the call you are making, but it might be your only solution for this device. Just make your own playTone method and have it call the Nokia function for this device (and maybe other Nokia devices if need be) and the J2ME standard call on all other devices. You can accomplish this with the Netbeans ME Preprocessor.

http://www.theoreticlabs.com/dev/api/nokia-ui-1.1/com/nokia/mid/sound/Sound.html

Fostah
Thanks, I was hoping that I could keep it generalized, but if this is the only way then I guess I'll have to use the nokia ui sound class.
DoryuX