关于java应用程序中调用声音的问题,高手请进!!急
ha_fu 2007-06-29 02:25:28 public class MusicTie {
AudioStream as = null;
static InputStream in;
static {
try {
in = new FileInputStream("tie.wav");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public MusicTie() throws IOException {
as = new AudioStream(in);
}
public static void main(String[] args) throws Exception {
MusicTie t = new MusicTie();
t.play();
Thread.sleep(2000);
MusicTie t1 = new MusicTie();
t1.play();
}
public void play() {
AudioPlayer.player.start(as);
}
}
那个 in 只能从硬盘读一次,as 最好也只 as 也new一次,调用一次play就可以发一次声音,但不知道程序怎么写,请高手指点,