I'm trying to play mp3 music in Processing, using the Minim library, but when i try to export it as an application, it keeps crashing and showing me this:
Exception in thread "Thread-6" java.lang.OutOfMemoryError: Java heap space at processing.app.Base.loadBytesRaw(Base.java:2131) at processing.app.Sketch.exportApplication(Sketch.java:2364) at processing.app.Sketch.exportApplication(Sketch.java:2194) at processing.app.Sketch.exportApplicationPrompt(Sketch.java:2178) at processing.app.Editor$DefaultExportAppHandler.run(Editor.java:1948) at java.lang.Thread.run(Thread.java:619)
I tried to increase the maximum memory to as much as when it will still run the pde in Processing (1300 mb). I have 2gb installed on my system and I'm using Windows 7..
I want to export and application, because i would like to use an absolute path for playing songs.
I read another way of using an absolute path with Minim, is by signing the applet.
But the problem is, it won't compile, when you put in an absolute path in the first place!
So that's why i thought to try to export it as an application, that you can put in your music folder.
but I don't know what to do next now.
Can anyone help me with this?
If you need more information, please tell me.
Thank you!
This is my code:
import ddf.minim.*;
AudioPlayer player;
Minim minim;
String Song = "Song1.mp3";
// load a file, give the AudioPlayer buffers that are 2048 samples long
player = minim.loadFile(Song1, 2048);
// play the file
player.play();
}
void draw()
{
background(0);
// draw the current level of the left and right sample buffers
// level() returns a value between 0 and 1, so we scale it up
noStroke();
float VolumeLeft = player.left.level();
float VolumeRight = player.right.level();
// draw the waveforms
// the values returned by left.get() and right.get() will be between -1 and 1,
// so we need to scale them up to see the waveform
stroke(255);
//Tell if song is paused
fill(255);
if ( player.isPlaying() )
{
text("The player is playing: " + Song, 5, 15);
}
else
{
text("The player is paused.", 5, 15);
}
}
void keyPressed()
{
if ( key == 'l' )
{
player.loop(1);
}
if ( key == 'p' )
{
player.play();
}
if ( key == 's' )
{
player.pause();
}
if ( key == 'f' )
{
player.skip(10000);
}
if ( key == 'b' )
{
player.skip(-10000);
}
}
void stop()
{
// always close Minim audio classes when you are done with them
player.close();
// always stop Minim before exiting.
minim.stop();