Beep on Motorola Symbol MC3090

868 views Asked by At

I'm using JAVA ME 1.4 and WTK and LWUIT and want to get a beep in the Java application running in PhoneME.

I've discovered several ways on google, but none of them is working.

My last try was using Display.getInstance().playBuiltinSound(Display.SOUND_TYPE_ERROR) but without success.

Another was: AlertType.WARNING.playSound(Display.getDisplay(midlet)) ; also not working

And this one: Playing Audio with J2ME ; no success

Can somebody help to find a generic way to play a beep on JAVA ME?

1

There are 1 answers

1
mr_lou On

If it was me, I would use the Player object to play an AMR file, or a MIDI file.

AMR is the most widely supported streamed audio format for JavaME. You can convert WAV files to AMR easily using various converters.

Using the Player object is very straight forward. Here is an example for playing a MIDI. First create the Player object:

Player myPlayer = Manager.createPlayer(getClass().getResourceAsStream("music.mid"), "audio/midi"); // For AMR use audio/amr

After this you may be able to just call myPlayer.start(), but here's the trouble: Some devices require you to first call realize() and prefetch(), while these exact calls will mess up the playback on other devices. So to get playback working on most possible devices, you just throw in a few try/catch blocks:

try {
    myPlayer.realize();
} catch (Exception e) {} // Didn't work? Oh well, never mind.

try {
    myPlayer.prefetch();    
} catch (Exception e) {} // Again, we don't care if it didn't work.

try {
    myPlayer.start();   
} catch (Exception e) {}

Using that approach should give you the a working sound on most possible devices.

Finding a beep sound online to use shouldn't be a problem.