为什么会没有声音?

Crazy_AnBoo 2008-03-01 11:23:09

import java.applet.AudioClip;
import java.awt.*;



public class Time extends javax.swing.JApplet implements Runnable
{
AudioClip aud;
AudioClip bud;
Thread thr;

public void init()
{
aud=getAudioClip(getCodeBase(),"Global.wav");
bud=getAudioClip(getCodeBase(),"Folder.wav");

}

public void start()
{
if(thr==null)
{
thr = new Thread(this);
thr.start();
}
}

public void stop()
{
if(thr!=null)
{
if(aud!=null)
aud.stop();

thr=null;
}
}

public void run()
{
if(aud!=null)
{
aud.loop();
}
Thread thisThread=Thread.currentThread();
while(thr==thisThread)
{
try{
Thread.sleep(5000);
if(bud!=null)
{
bud.play();
}

}
catch(InterruptedException e)
{
System.out.println("出错了...");
}
}
}

public void paint(Graphics screen)
{
Graphics2D aa=(Graphics2D)screen;
aa.drawString("play...", 10, 10);
}
}



运行正常,但是就是没有声音?
为什么会这样?
...全文
128 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wtttk 2008-03-02
  • 打赏
  • 举报
回复
打声音文件放到getCodeBase()目录下试试
Crazy_AnBoo 2008-03-02
  • 打赏
  • 举报
回复
??

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧