0

I'm trying to play a music file in Eclipse using Minim. But I'm getting this error:

    ==== JavaSound Minim Error ====
    ==== java.io.FileNotFoundException: groove.mp3

    === Minim Error ===
    === Couldn't load the file groove.mp3

In the Processing editor the file has to be in the data folder of the sketch, but where should I put my file when I'm using Eclipse?

My code:

    import ddf.minim.AudioPlayer;
    import ddf.minim.Minim;
    import processing.core.PApplet;

    public class test extends PApplet {
       Minim minim;
       AudioPlayer player;

       public static void main(String[] args) {
        PApplet.main(test.class);
        }

       @Override
       public void settings() {
        size(600, 600);
        }

       @Override
       public void setup() {
        background(255);
        minim = new Minim(this);
        player = minim.loadFile("groove.mp3");
        //player.play();
       }

        @Override
        public void draw() {
       } 
     }
Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
quoci
  • 2,940
  • 1
  • 9
  • 21
  • Just curious: did it turn out that moving the minim and player assignment statements out of setup and into settings was unnecessary? Did you need to append "/data" to your mp3 file name? – A. Greyson Jan 19 '19 at 19:02

2 Answers2

1

You put the sound file in your data directory, but also try moving the two lines below out of setup and into the settings method.

minim = new Minim(this);
player = minim.loadFile("data/groove.mp3"); // path includes data

This is what worked for me.

A. Greyson
  • 81
  • 1
  • 5
0

I don't know where to put it off the top of my head, but here's what I'd do to figure it out:

Try printing this out:

System.out.println(new File().getAbsolutePath());

This will tell you which directory you're running from.

Generally, I would guess that files would go in the top level of your project, next to the src directory. You could also try adding a data directory there and putting your file in there.

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107