Sound is played several times, but suddenly stop playing.

See this problem: Everytime the player sprite catches an item on game, this sound is played. It works well, but after 14 or 13 times, the sound doesn't play anymore and the only thing I've got is this exception message:

javax.microedition.media.MediaException: audio device

Now the code is called when it must play the sound:

try{

InputStream is = getClass().getResourceAsStream("beep.wav");

Player sound = Manager.createPlayer(is,"audio/x-wav");

sound.realize();

sound.prefetch();

sound.start();

}

catch(Exception e){

System.out.println(e);

}

What's going on here?

Thanks for your reply!

[915 byte] By [coffee95a] at [2007-11-27 8:17:08]
# 1
Create the player, realize, and prefetch once. When you need to play the sound, reuse it instead of creating it every time the sound needs to be played.I've seen this type of problem on an emulator have you tried it on a real device?
jonathan.lea at 2007-7-12 20:02:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
I've tested on Sony Ericsson emulator, but I haven't tested on real device.I'll try to make the changes you sugested.Thanks!
coffee95a at 2007-7-12 20:02:15 > top of Java-index,Java Mobility Forums,Java ME Technologies...