java - MP3 文件无法使用 jl 库播放

标签 java mp3

编辑:解决了它,显然你不必输入下划线而不是空格。

我正在尝试制作一个 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/

相关文章:

java - 来自 javax.print 库的不一致结果

java - 将泛型类传递给 java 函数?

ffmpeg - 如何使用 ffmpeg 将音频文件拆分为 HLS 兼容的 block ? (mp3 格式)

ios - 将 currentPlaybackTime 与 MPMoviePlayerController 一起用于 mp3 文件

android - 从媒体资源更改按钮上的图片后,Android MediaPlayer停止播放表单素材资源

java - struts2 的 log4j 配置

java - EditText 在 NestedScrollView 内不可滚动

java - 使用枚举参数自动推断返回类型

python - 在 python 中使用 super 对撞机

java - 如何识别音频流格式?