I want to play videos in two windows by using just one single sketch in Processing. And I also want to use serial communication.. serial communication does well but a video doesn't work. I guess the program can't find where video is.
I've searched more than one window of a single sketch in Processing. I referred to this. How to create more than one window of a single sketch in Processing?
Here is the codes that I wrote.
I hope you help me please
Code
import processing.video.*;
import processing.serial.*;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
Movie mov;
void setup() {
size(100, 100);
String[] args = {"TwoFrameTest"};
SecondApplet sa = new SecondApplet();
ThirdApplet na = new ThirdApplet();
PApplet.runSketch(args, sa);
PApplet.runSketch(args, na);
String portName = Serial.list()[1];
myPort = new Serial(this, portName, 9600);
sa.mov = new Movie(this, "transit.mov");
sa.mov.loop();
}
void draw() {
background(0);
ellipse(50, 50, 10, 10);
if (myPort.available() > 0) {
if ( (val = myPort.readStringUntil(ENTER)) != null ) val = trim(val);
else return;
if (val != null) {
println(val);
}
}
}
public class SecondApplet extends PApplet {
public Movie mov;
public void settings() {
size(500, 500);
}
public void draw() {
fill(0);
ellipse(100, 50, 10, 10);
if ("3Low".equals(val)) {
fill(255,random(255),200);
ellipse(60,20,100,100);
}
sa.image(sa.mov,0,0);
}
}
public class ThirdApplet extends PApplet {
public void settings() {
size(500, 500);
}
public void draw() {
fill(0);
ellipse(100, 50, 10, 10);
if ("3Low".equals(val)) {
fill(255,random(255),200);
ellipse(60,20,100,100);
}
}
}