0

I'm trying to play a mp3 but link it from the local folder (Zoo/src/wolfHowl.mp3) so I could export the project and run it on other computers without changing file link Thanks for help in advanced

    protected void howl() {
        System.out.println("Howl!!!");
        JFXPanel jfxPanel = new JFXPanel(); //needed for MediaPlayer();
        String callFile= "File:///C:/Users/Pol/workspace/Zoo/src/wolfHowl.mp3";
        Media  call= new Media(callFile);
        MediaPlayer noiseCreation = new MediaPlayer(call);
        noiseCreation.play();
    }
user1642671
  • 85
  • 2
  • 11

1 Answers1

1

You should use relative path instead of absolute path. Absolute path is machine dependent.

In your case the right path is "/src/wolfHowl.mp3"

Check the answers to similar question here.

You can read more on path operations here.

Community
  • 1
  • 1
vatsal
  • 3,803
  • 2
  • 19
  • 19