clip.start();
return true;
}
}
try {
Clip clip = AudioSystem.getClip();
clip.addLineListener(this);
AudioInputStream stream = null;
try {
stream = AudioSystem
.getAudioInputStream(fileOrURL.asURL());
} catch (IOException ex) {
// Handle jar urls from WebStart or the installer
try {
URL possibleJarURL = ClassUtilities.jarURLEntryResource(fileOrURL.getExpression());
stream = AudioSystem
.getAudioInputStream(possibleJarURL);
} catch (Exception ex2) {
IOException ioException = new IOException("Failed to open \""
+ fileOrURL.getExpression() + "\".");
ioException.initCause(ex);
throw ioException;
}
}
clip.open(stream);
clip.start();
_clips.add(clip);
} catch (Exception e) {
throw new IllegalActionException(this, e,
"Error opening audio file or URL: "
+ fileOrURL.getExpression());
}
} else {
// Restart the last clip.
Clip clip = _clips.get(_clips.size() - 1);
// NOTE: Possible race condition: could become inactive
// before the stop() is called, which could result in
// two stop notifications to the update() method.
// Will the Clip give to stop notifications?
if (clip.isActive()) {
clip.stop();
}
clip.setFramePosition(0);
clip.start();
}
}
return true;
}