public class SoundPlayer {
/**
* 播放声音
* @param soundFile 声音文件的相对于SoundPlayer的位置
*/
public static void soundPlay(String soundFile) {
try {
InputStream is = SoundPlayer.class.getResourceAsStream(soundFile);
AudioStream soundStream = new AudioStream(is);
AudioPlayer.player.start(soundStream);
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 播放声音
* @param soundFile 声音文件的相对于SoundPlayer的位置
*/
public static void soundPlay(String soundFile) {
try {
InputStream is = SoundPlayer.class.getResourceAsStream(soundFile);
AudioStream soundStream = new AudioStream(is);
AudioPlayer.player.start(soundStream);
} catch (Exception e) {
e.printStackTrace();
}
}
}