I have created a program where I can play a song, However I cannot get it to pause/stop and when I click the play button again the song loops over and over again. How can i get the song to pause or stop?
Here's my source code below to play a song:
public void sound(String nm) {
AudioStream BGM; //Backround Music
try {
InputStream test = new FileInputStream("./"+nm+".wav");
BGM = new AudioStream(test);
AudioPlayer.player.start(BGM);
}
catch (IOException error) {
JOptionPane.showMessageDialog(null, error.getMessage());
}
}