I have here a code which listens to the input of the user.
System.out.println(message);{
if(message.equals("play")){
try {
AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File("c:/DancingMachupapet/Test.wav"));
Clip clip = AudioSystem.getClip();
// getAudioInputStream() also accepts a File or InputStream
clip.open(inputStream);
clip.start();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Close to exit!");
}
});
}catch (IOException e) {
}
}
if(message.equals("hoy")){
try {
AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File("c:/DancingMachupapet/ThinkOfManu.wav"));
Clip clip = AudioSystem.getClip();
// getAudioInputStream() also accepts a File or InputStream
clip.open(inputStream);
clip.start();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Close to exit!");
}
});
}catch (IOException e) {
}
}
}
THis code works when it sees the message 'hoy' and 'play' it will play 'ThinkOfManu.wav' and 'Test.wav' repectively. It works but my problem is when i simultaneously input the 'hoy' and 'play', the 2 wav files plays as well simultaneously.
What I want to happen is that when ThinkOfManu.wav is playing and I call Test.wav, the ThinkOfManu should stop and play the Test.wav. NOT SIMULTANEOUSLY.
Please help me here.