我修改了音频播放器并在此处发布了一个新的(而不是重复的)问题:BigClip Won't Play .wav File
我写了一个音频播放器,它有效,但现在却没有。这是代码:
package me.pogostick29.audiorpg.audio;
import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.net.MalformedURLException;
public class AudioPlayer {
private AudioPlayer() { }
private static AudioPlayer instance = new AudioPlayer();
public static AudioPlayer getInstance() {
return instance;
}
public void play(String name) {
AudioClip clip = null;
try { clip = Applet.newAudioClip(new File("audio/" + name + ".wav").toURI().toURL()); }
catch (MalformedURLException e) { e.printStackTrace(); }
clip.play();
}
public void playDialogue(String character, String name) {
play("people/" + character + "/" + name);
}
}
但是,当我尝试播放位于此处的音频文件(http://icap.me/i/rNIXeCfScy.png)
时 使用
AudioPlayer.getInstance().playDialogue("blacksmith", "blacksmith1");
来自另一个班级,它什么也没做。
提前感谢您的帮助!