我把声音文件放到我的当前项目的sound文件夹
添加声音的类:
import sun.audio.*; 
import java.io.*;
public class Sound {
Sound(String Filename)
{
try{
InputStream in = new FileInputStream(Filename); AudioStream as = new AudioStream(in);
AudioPlayer.player.start(as);
AudioPlayer.player.stop(as);
}catch(Exception e)
{
e.printStackTrace();
}
}
}
按钮事件中的调用:
Sound s=new Sound(./sound/folder.wav);
各位看看我的程序错在哪里,该怎么改;
声音总是不响

解决方案 »

  1.   

    Sound s=new Sound(./sound/folder.wav); 这样??你的构造方法里面是接收一个字符串哦。。再看看是不是路径错了。
      

  2.   

    是我写错了Sound s=mew Sound("./sound/folder.wav");
    去google上查,说是要下载jmf,那jmf 到底怎么声明?怎么使用啊?
    有没有高手给点简单点的代码?不要复杂的只要能输出声音就行!!!
      

  3.   

    http://developer.ccidnet.com/art/322/20030528/47658_1.html
    这篇文章很好,还提供源程序下载