Hi guys!
I have created a simple game using J2ME. The game is working great and works on almost any J2ME phone because the graphics are highly scalable. I wanted to add a little sound, but this is giving me some problems.
The game has a grid and a selector which is moved when the "keyPressed" method is fired. I have tried adding the following code into this method, and whilst the sound does in fact play, so does the default beep of the phone. I have tried removing "super.keyPressed(keyCode)", but this did not appear to make any difference.
if (moveSoundPlayer != null) {
try {
moveSoundPlayer.setMediaTime(0);
moveSoundPlayer.start();
} catch(Exception ex) {
// Sound failed, disable!
moveSoundPlayer.deallocate();
moveSoundPlayer = null;
}
}
In my constructor I have:
try {
moveSoundPlayer = Manager.createPlayer(BoardDisplay.class.getResourceAsStream("move.wav"), "audio/x-wav");
moveSoundPlayer.realize();
moveSoundPlayer.prefetch();
} catch(Exception ex) {
if (moveSoundPlayer != null) {
moveSoundPlayer.deallocate();
moveSoundPlayer = null;
}
}
How can I disable the default beep?
Many thanks!
Lea Hayes
p.s. I am testing this on a "Nokia 6220 Classic" phone.

Reply With Quote

