import processing.serial.*;
import processing.video.*;
import processing.net.*;
Movie loop, loop1;
Server server;
Serial myPort; // Create object from Serial class
int y;
String val; // Data received from the serial port
String in;
void setup() {
size(1600, 900);
server = new Server(this, 5204);
String portName = Serial.list()[3]; //change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial(this, portName, 9600);
myPort.bufferUntil('\n');
loop = new Movie(this, "1.mov"); //movie from data dir
loop1 = new Movie(this, "2.mov"); //movie from data dir
loop1.loop();
loop.loop();
}
void draw(){
println(val);
Client client = server.available();
if (client != null) {
server.write(val);
}
if (y<50) {
loop1.play();
image(loop1, 0, 0);
} else {
image(loop, 0, 0);
if (loop1.time() != 0){
loop1.jump(0);
loop1.stop();
}
}
}
void serialEvent( Serial myPort) {
if ( myPort.available() > 0)
{ // If data is available,
val = myPort.readStringUntil('\n'); // read it and store it in val
}
if (val != null) {
val=trim(val);
y = Integer.parseInt(val);
server.write(y);
}
}
void movieEvent(Movie m) {
m.read();
}
****client:****
import processing.serial.*;
import processing.video.*;
import processing.net.*;
Movie loop, loop1;
Client client;
int y=0;
void setup() {
size(1600, 900);
client = new Client(this, "000.000.00.000", 5204); // ip address server?
frameRate(25);
smooth();
noCursor();
loop = new Movie(this, "2x.mov"); //movie from data dir
loop1 = new Movie(this, "122.mov"); //movie from data dir
loop1.loop();
loop.loop();
}
void draw() {
println(y);
if (y<50) {
loop1.play();
image(loop1, 0, 0, 1280, 800);
} else {
image(loop, 0, 0, 1280, 800);
if (loop1.time() != 0) {
loop1.jump(0);
loop1.stop();
}
}
}
void clientEvent (Client client) {
if (client.available() > 0) {
// Read message as a String, all messages end with an asterisk
y = client.read();
}
}
void movieEvent(Movie m) {
m.read();
}
Comments
Code we used:
Make sure you store the movie's in the data directory. And fill in the right ip address
Hardware used: Arduino uno, Distance-sensors, 3 HD Screens, 3 iMacs, Ethernet router, Headphone
****Server:****
****client:****