Out of Memory Problems with GSVIDEO
in
Contributed Library Questions
•
2 years ago
Following sketch will stop with an error after a while. The Error message says my mac is out of memory. Everytime i load a new video, i delete the old one, but still it seems that something will fill my memory all the time. Would be very very nice, if someone can see the solution.
import codeanticode.gsvideo.*;
import processing.serial.*;
import cc.arduino.*;
import fullscreen.*;
GSMovie movie;
Arduino arduino;
FullScreen fs;
int state = 0;
int lastState = 0;
Boolean einwurf = false; //
Boolean buttonPressed = false;
Boolean startAmpel = true;
Boolean winner = false;
Boolean info = false; // Debug-Informationen
PFont fontA;
boolean on = true;
void setup() {
size(1680, 1050);
fs = new FullScreen(this);
fs.enter();
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(0, Arduino.INPUT); // Lichtsensor
arduino.pinMode(2, Arduino.INPUT); // Taster
arduino.pinMode(12, Arduino.OUTPUT); // LED
arduino.digitalWrite(12, Arduino.HIGH); // LED an
playVideo("00");
}
void draw() {
checkArduino();
switch(state) {
case 0: // "Insert Coin"-VideoLoop / video00
if (movie.isPlaying() != true) {
playVideo("00");
lastState = 0;
}
if (einwurf == true && lastState != 3) {
lastState = 0;
state = 1;
einwurf = false;
}
break;
case 1:
int zufallsvideo;
if(winner == false){
zufallsvideo = int(random(1,3));
}
else{
zufallsvideo = int(random(3,5));
}
if (movie.isPlaying() != true) {
playVideo("0"+str(zufallsvideo));
lastState = 1;
}
if (buttonPressed == true && lastState != 3) {
state = 2;
buttonPressed = false;
movie.pause();
}
break;
case 2:
if (movie.isPlaying() == false && startAmpel == true) {
playVideo("05");
startAmpel = false;
}
if (movie.isPlaying() == false && startAmpel == false) {
state = 3;
startAmpel = true;
}
break;
case 3:
int temp = int(random(6, 13));
if (movie.isPlaying() != true) {
if (temp < 10) {
playVideo("0"+str(temp));
}
else {
playVideo(str(temp));
}
if (temp >= 9 || temp <= 12) {
println("WIN!!!!!");
winner = true;
lastState = 3;
state = 1;
}
if (temp >= 6 || temp <= 8) {
println("LOOSE!!!!!");
winner = false;
lastState = 3;
state = 0;
}
}
break;
}
if (movie != null) {
image(movie, 0, 0, width, height);
}
}
void movieEvent(GSMovie movie) {
movie.read();
}
/*void insertCoinAnim() {
int currentMillies = millis();
fill(255);
textAlign(CENTER);
text("Activate Lightsensor", width/2, height/2);
/*delay(00);
fill(0);
rect(0,0,width,height);
}*/
void playVideo(String vidNum) {
if (movie != null) {
movie.stop();
movie.delete();
}
println("Video "+vidNum+" is playing");
movie = new GSMovie(this, "video"+vidNum+".avi");
movie.play();
// movie.volume(0);
}
void keyPressed() {
if (key == 'm') {
einwurf = true;
}
if (key == 'b') {
buttonPressed = true;
}
if (key == 's') {
movie.stop();
}
if (key == 'i') {
info = !info;
}
}
void checkArduino() {
if(info){
println("Lichtsensor: " + arduino.analogRead(2));
println("Taster: " + arduino.digitalRead(0));
}
if (arduino.digitalRead(2) == Arduino.HIGH) {
buttonPressed = true;
println("Taste wurde gedrückt");
}
else {
buttonPressed = false;
}
if (arduino.analogRead(0) > 590) {
einwurf = true;
println("Münze wurde eingeworfen");
}
else {
einwurf = false;
}
}
void mousePressed() {
exit();
}
1