我使用Eclipse Juno并收到以下错误:
Access restriction:The type AudioPlayer is not accessible due to restriction
on required library C:\Program\Files\Java\jre6\lib\rt.jar
AudioStream
和AudioData
非常相似。
如何解决这些错误?
答案 0 :(得分:0)
你试过AudioClip吗?
public static final Sound sound= new Sound("/sound.wav");
private AudioClip clip;
private Sound(String name) {
try {
clip = Applet.newAudioClip(Sound.class.getResource(name));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void play() {
try {
new Thread() {
public void run() {
clip.play();
}
}.start();
} catch (Throwable e) {
e.printStackTrace();
}
}