We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm fairly new to processing and I'm trying to play a video depending on a variable called feed. if feed == 30 I want the full movie 1 to play and then stop, if feed == 20 I want to play and then stop movie 2
It seems the trigger to play the movie works once and then it doesn't. Where do you think is my error?
Here is the code:
import processing.serial.*;
import processing.video.*;
Movie[] movies = new Movie[2];
float[] movieduration = new float[2];
int movienumber;
boolean movieplay = false;
boolean moviezero = false;
boolean movieone = false;
float feed = 100;
Serial myPort;
void setup() {
size( 1280, 720 );
movies = new Movie[] {
new Movie(this, "awesome.mov"),
new Movie(this, "finalmov.mov"),
};
for (int i=0; i<movies.length; i++) {
movies[i].play();
movies[i].jump(0);
movies[i].stop();
movieduration[i] = movies[i].duration();
}
println(Serial.list());
myPort = new Serial(this, Serial.list()[11], 9600);
myPort.bufferUntil('\n');
}
void draw() {
float movietime = movies[0].time();
float movietimeone = movies[1].time();
background( 127, 222, 333 );
if ( feed == 30 && movietime<1.8 && movieplay == false) {
movies[0].play();
movieplay = true;
moviezero = true;
}
if (movietime==movieduration[0]) {
println(movietime);
movies[0].pause();
movieplay = false;
moviezero = false;
}
if ( feed == 20 && movietimeone<1.8 && movieplay == false) {
movies[1].play();
movieplay = true;
movieone = true;
}
if (movietimeone==movieduration[1]) {
movies[1].pause();
movieplay = false;
movieone = false;
}
if(movieone == true) {
image(movies[1], 0, 0);
}
if(moviezero == true) {
image(movies[0], 0, 0);
}
}
void serialEvent(Serial p) {
String inString = p.readString();
inString = trim( inString );
println( inString );
feed = int(inString);
}
void movieEvent(Movie m) {
m.read();
}
Answers
I have updated the code, still the same problem, the code runs once and then the keypressed or mousepressed don't trigger the movie. What I'm doing wrong?