/**
* Opens a new sound and replaces the old one. If object is set to loop the sound (isLoop = true) then it will loop
*
* @param file - the file path and name of the audio to play
*/
public void open(File file) {
try {
clip.stop();
clip.close();
audio = AudioSystem.getAudioInputStream(file);
clip.open(audio);
volumeControl = (FloatControl)clip.getControl(FloatControl.Type.MASTER_GAIN);
clip.start();
if(isLoop)
clip.loop(Clip.LOOP_CONTINUOUSLY);
else
clip.loop(0);
}
catch(UnsupportedAudioFileException uae) {
System.out.println(uae);
}
catch(IOException ioe) {
System.out.println(ioe);
System.out.println(file);
}
catch(LineUnavailableException lua) {
System.out.println(lua);
}
}
VNSound.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:VN-RW
作者:
评论列表
文章目录