编辑:解决了它,显然你不必输入下划线而不是空格。
我正在尝试制作一个 MP3 播放器。但当我运行程序时,似乎找不到/识别我的文件。我正在遵循本指南:https://www.youtube.com/watch?v=LavMuqK5Is0 ,完全按照他的做法,所以我认为要么是文件命名,要么是位置给了我这个问题。
我的路径在我的 GUI 中声明。它看起来像这样:
MC.Play("C:\Users\the4th\Desktop\school\HBO_ICT\Programmeren\MP3 Speler\All_Along_The_Watchtower");
public class MainClass {
FileInputStream FIS;
BufferedInputStream BIS;
public Player player;
public void Stop(){
if(player !=null){
player.close();
}
}
public void Play(String path){
try {
FIS = new FileInputStream(path);
System.out.println();
BIS = new BufferedInputStream(FIS);
player = new Player(BIS);
}
catch (FileNotFoundException | JavaLayerException ex) {
}
new Thread(){
@Override
public void run(){
try {
player.play();
}
catch (JavaLayerException ex) {
}
}
}.start();
}
}
最佳答案
尝试更改路径(“\”到“\\”或“/”):
MC.Play("C:\Users\the4th\Desktop\school\HBO_ICT\Programmeren\MP3 Speler\All_Along_The_Watchtower");
至
MC.Play("C:\\Users\\the4th\\Desktop\\school\\HBO_ICT\\Programmeren\\MP3 Speler\\All_Along_The_Watchtower");
关于java - MP3 文件无法使用 jl 库播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40177298/