Java里的AudioClip对象为何不能播放声音?编译和运行都没问题,就是不出声,求解!(代码如下)
importjava.applet.*;importjava.awt.*;importjava.awt.event.*;publicclassplay_audioclip...
import java.applet.*; import java.awt.*;
import java.awt.event.*;
public class play_audioclip extends Applet implements ActionListener{
AudioClip clip;
Button buttonPlay,buttonLoop,buttonStop;
public void init(){
clip=getAudioClip(getCodeBase(),"无法言语.wav");
buttonPlay=new Button("开始播放");
buttonLoop=new Button("循环播放");
buttonStop=new Button("停止播放");
buttonPlay.addActionListener(this);
buttonLoop.addActionListener(this);
buttonStop.addActionListener(this);
add(buttonPlay);
add(buttonLoop);
add(buttonStop);
}
public void stop(){
clip.stop();
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==buttonPlay){clip.play();}
else if(e.getSource()==buttonLoop) {clip.loop();}
if(e.getSource()==buttonStop){clip.stop();}
}
} 展开
import java.awt.event.*;
public class play_audioclip extends Applet implements ActionListener{
AudioClip clip;
Button buttonPlay,buttonLoop,buttonStop;
public void init(){
clip=getAudioClip(getCodeBase(),"无法言语.wav");
buttonPlay=new Button("开始播放");
buttonLoop=new Button("循环播放");
buttonStop=new Button("停止播放");
buttonPlay.addActionListener(this);
buttonLoop.addActionListener(this);
buttonStop.addActionListener(this);
add(buttonPlay);
add(buttonLoop);
add(buttonStop);
}
public void stop(){
clip.stop();
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==buttonPlay){clip.play();}
else if(e.getSource()==buttonLoop) {clip.loop();}
if(e.getSource()==buttonStop){clip.stop();}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询