MP3文件无法使用jl库播放

时间:2016-10-21 12:57:37

标签: 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();
    }

}

1 个答案:

答案 0 :(得分:0)

尝试更改路径(“\”为“\\”或“/”):

$options = array(
                CURLOPT_URL            => $url,
                CURLOPT_HEADER         => false,    
                CURLOPT_VERBOSE        => true,
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_FOLLOWLOCATION => true,
                CURLOPT_SSL_VERIFYPEER => false,    // for https
                CURLOPT_USERPWD        => $username . ":" . $password,
                CURLOPT_HTTPAUTH       => CURLAUTH_DIGEST

        );
        $ch = curl_init();
        curl_setopt_array( $ch, $options );
        try {
          $raw_response  = curl_exec( $ch );
          // validate CURL status
          if(curl_errno($ch))
              throw new Exception(curl_error($ch), 500);
          // validate HTTP status code (user/password credential issues)
          $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          if ($status_code != 200)
              throw new Exception("Response with Status Code [" . $status_code . "].", 500);
        } catch(Exception $ex) {
            if ($ch != null) curl_close($ch);
            throw new Exception($ex);
        }
        if ($ch != null) curl_close($ch);
        return json_decode($raw_response);

MC.Play("C:\Users\the4th\Desktop\school\HBO_ICT\Programmeren\MP3 Speler\All_Along_The_Watchtower");