if (player.isPlaying()) {
player.stop();
}
// get and AudioInputStream from the resource
AudioFileFormat fmt = null;
try {
fmt = AudioSystem.getAudioFileFormat(list.get(index).getInputStream());
} catch (UnsupportedAudioFileException | IOException ex) {
LOG.log(Level.SEVERE, null, ex);
}
AudioInputStream is = SoundSystem.getAudioInputStream(list.get(index));
// if we have a listener, tell about it
if (listener != null) {
String title = (String) fmt.properties().get("title");
listener.newEvent("Audio: \"" + title + "\" now playing.");
}
// start playing this piece
player.play(is);