// Make sure we have a real file, otherwise, disable the buttons
if ((f == null) || (f.getName() == null)) {
fileLabel.setText("no audio selected");
playButton.setEnabled(false);
stopButton.setEnabled(false);
return;
}
// Ok, seems the audio file is real, so load it and enable the buttons
String name = f.getName();
if (name.equals(currentName)) {
return;
}
if (currentClip != null) { currentClip.stop(); }
currentName = name;
try {
URL u = new URL("file:///" + f.getAbsolutePath());
currentClip = new AppletAudioClip(u);
}
catch (Exception e) {
e.printStackTrace();
currentClip = null;
fileLabel.setText("Error loading clip.");
}
fileLabel.setText(name);
playButton.setEnabled(true);
stopButton.setEnabled(true);