I'm using the Minim 2.2.0 library with JAVA. The library requires us to define a helper class defining two methods and pass an object of this class to the Minim constructor. I wrote the MinimHelper class as follows.
public class MinimHelper {
String sketchPath( String fileName ) {
return "C:\\Users\\Martin\\Downloads\\"+fileName;
}
InputStream createInput(String fileName) {
InputStream is = null;
try{
is = new FileInputStream(sketchPath(fileName));
}
catch(Exception e){
System.out.println(e.toString());
}
return is;
}
}
And I wrote my main as follows
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
AudioPlayer player;
Minim minim = new Minim (new MinimHelper());
player = minim.loadFile("Butterfly.mp3");
player.play();
}
}
However, I'm getting the following error in the console.
==== JavaSound Minim Error ====
==== Couldn't find a sketchPath method on the file loading object provided!
==== File recording will be disabled.
==== JavaSound Minim Error ====
==== Couldn't find a createInput method in the file loading object provided!
==== File loading will be disabled.
==== JavaSound Minim Error ====
==== Error invoking createInput on the file loader object: null
Exception in thread "main" java.lang.NullPointerException
at ddf.minim.javasound.JSMinim.getAudioRecordingStream(Unknown Source)
at ddf.minim.Minim.loadFile(Unknown Source)
at ddf.minim.Minim.loadFile(Unknown Source)
at Main.main(Main.java:9)
Please tell me where I'm doing wrong.