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就可以发一次声音,但不知道程序怎么写,请高手指点,
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就可以发一次声音,但不知道程序怎么写,请高手指点,
上面的 话写错了,改下.