I have a problem with playing more than 2 sound files in a game I'm developing now in j2me MIDP2 in eclipse. Please advice me the best way for playing multiple "wav" sound files. I created the following method that is called once when the program starts
public void setSound()
{
System.out.println("Sound on");
try {
p1=Manager.createPlayer(is1, "audio/X-wav");
p2=Manager.createPlayer(is2, "audio/X-wav");
p3=Manager.createPlayer(is3, "audio/X-wav");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MediaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
and every time I need to play one of the sounds I stop the two other players (to insure that no one of them is running p2.stop(); p3.stop();
) and start the third one (p1.start();
) and every time I have two players stopped (being in PREFETCHED State) the third one is not running and exceptions are thrown.