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?
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:
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:
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.