unable to prepare stream error in minim
in
Core Library Questions
•
18 days ago
Hi,
I am new in processing.
I have a program.
import ddf.minim.*;
AudioPlayer player;
Minim minim;
boolean playing;
int savedtime=millis();
void setup(){
background(0);
size(640,480);
playing=false;
minim=new Minim(this);
}
void draw(){
background(0);
int passedtime=millis()-savedtime;
if(passedtime>=3000)
{
println("3 sec passed");
savedtime=millis();
float ran=random(2);
int co=parseInt(ran+.5);
//println(co);
if(co==0)
{
if(playing)
{
player.close();
minim.stop();
}
player=minim.loadFile("song1.mp3");
player.play();
playing=true;
}
else if(co==1)
{
if(playing)
{
player.close();
minim.stop();
}
player=minim.loadFile("song2.mp3");
player.play();
playing=true;
}
}
}
void stop(){
player.close();
minim.stop();
super.stop();
}
My problem is, when running this program, after some time I am getting this error.
java.lang.RuntimeException: unable to prepare stream
at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.close(PulseAudioDataLine.java:309)
at org.classpath.icedtea.pulseaudio.PulseAudioSourceDataLine.close(PulseAudioSourceDataLine.java:333)
at ddf.minim.javasound.JSBaseAudioRecordingStream.run(JSBaseAudioRecordingStream.java:159)
at java.lang.Thread.run(Thread.java:662)
Is this due to loading the files from draw(), Is there any solution?
I am new in processing.
I have a program.
import ddf.minim.*;
AudioPlayer player;
Minim minim;
boolean playing;
int savedtime=millis();
void setup(){
background(0);
size(640,480);
playing=false;
minim=new Minim(this);
}
void draw(){
background(0);
int passedtime=millis()-savedtime;
if(passedtime>=3000)
{
println("3 sec passed");
savedtime=millis();
float ran=random(2);
int co=parseInt(ran+.5);
//println(co);
if(co==0)
{
if(playing)
{
player.close();
minim.stop();
}
player=minim.loadFile("song1.mp3");
player.play();
playing=true;
}
else if(co==1)
{
if(playing)
{
player.close();
minim.stop();
}
player=minim.loadFile("song2.mp3");
player.play();
playing=true;
}
}
}
void stop(){
player.close();
minim.stop();
super.stop();
}
My problem is, when running this program, after some time I am getting this error.
java.lang.RuntimeException: unable to prepare stream
at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.close(PulseAudioDataLine.java:309)
at org.classpath.icedtea.pulseaudio.PulseAudioSourceDataLine.close(PulseAudioSourceDataLine.java:333)
at ddf.minim.javasound.JSBaseAudioRecordingStream.run(JSBaseAudioRecordingStream.java:159)
at java.lang.Thread.run(Thread.java:662)
Is this due to loading the files from draw(), Is there any solution?
1