Final Project

I have two versions of code. Both that look to me like they absolutely should work. After hours and days of fishing around the Processing site, I am starting to get scared that it isn't going to be able to process my video fast enough. I also can get the window fullscreen, but not the image. I have tried so much I don't know what to do. I can get it to sometimes, with really simple code, play a video one after another, but I can't usually get it to delay until playing the next video for as long as I ask it to.

here are 2 versions of code:
import processing.video.*;
Movie myMovie;
import processing.serial.*;
Serial port;
float getByte = -1;
float oldByte = 0;
float difference = 0;
Movie CP1;
Movie CP2;
Movie CP3;
Movie CP4;
Movie CP5;
Movie CP6;
Movie BangItOut1;
Movie BangItOut2;
Movie BangItOut3;
Movie Where1;
Movie Where2;
Movie Where3;
Movie WhereYou;
Movie Wait;
Movie FuckOff;
Movie IDontKnow;
Movie WasTalking;
Movie WaitStill;


void setup() {
size(screen.width, screen.height);
port = new Serial(this, Serial.list()[0], 9600);
WaitStill = new Movie(this, "WaitStill.mov");
CP1 = new Movie(this, "CP1.mov");
CP2 = new Movie(this, "CP2.mov");
CP3 = new Movie(this, "CP3.mov");
CP4 = new Movie(this, "CP4.mov");
CP5 = new Movie(this, "CP5.mov");
CP6 = new Movie(this, "CP6.mov");
BangItOut1 = new Movie(this, "BangItOut1.mov");
BangItOut2 = new Movie(this, "BangItOut2.mov");
BangItOut3 = new Movie(this, "BangItOut3.mov");
Wait = new Movie(this, "Wait.mov");
FuckOff = new Movie(this, "FuckOff.mov");
IDontKnow = new Movie(this, "WaitStill.mov");
WasTalking = new Movie(this, "WasTalking.mov");
Where1 = new Movie(this, "Where1.mov");
Where2 = new Movie(this, "Where2.mov");
Where3 = new Movie(this, "Where3.mov");
WhereYou new Movie(this, "WhereYou.mov");
}

void draw(){
image(myMovie, 0, 0);
WaitStill.loop();
getByte = port.read();
oldByte = getByte;
delay(40);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference > 200) {
WaitStill.stop();
CP1.play();
delay(9140);}
else {
WaitStill.loop();
exit();}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
CP1.stop();
CP2.play();
delay(2050);}
else {
CP1.stop();
myMovie = new Movie (this, "Where1.mov");
Where1.play();
delay(2050);
getByte = port.read();
if (getByte > 1000){
Where1.stop();
WaitStill.loop();
exit();}

else {
Where1.stop();
CP2.play();
delay (2050);}}
oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
CP2.stop();
CP3.play();
delay(6090);}
else{
CP2.stop();
myMovie = new Movie (this, "Where3.mov");
Where3.play();
delay(327000);
getByte = port.read();
if (getByte > 1000){
Where3.stop();
WaitStill.loop();
exit();}

else{
Where3.stop();
CP3.play();
delay(609000);}}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP4.mov");
myMovie.play();
delay(708000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Wait.mov");
myMovie.play();
delay(118000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP4.mov");
myMovie.play();
delay(708000);}}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP5.mov");
myMovie.play();
delay(109200);}
else{
myMovie.stop();
myMovie = new Movie (this, "Wait.mov");
myMovie.play();
delay(118000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP5.mov");
myMovie.play();
delay(109200);}}

delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP6.mov");
myMovie.play();
delay(813000);}
else{
myMovie.stop();
myMovie = new Movie (this, "WasTalking.mov");
myMovie.play();
delay(305000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP6.mov");
myMovie.play();
delay(813000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut1.mov");
myMovie.play();
delay(914000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where2.mov");
myMovie.play();
delay(2260);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut1.mov");
myMovie.play();
delay(914000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut2.mov");
myMovie.play();
delay(115000);}
else{
myMovie.stop();
myMovie = new Movie (this, "IDontKnow.mov");
myMovie.play();
delay(320000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut2.mov");
myMovie.play();
delay(115000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut3.mov");
myMovie.play();
delay(99100);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where1.mov");
myMovie.play();
delay(205000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut3.mov");
myMovie.play();
delay(99100);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "FuckOff.mov");
myMovie.play();
delay(213000);}
else{
myMovie.stop();
myMovie = new Movie (this, "FuckOff.mov");
myMovie.play();
delay(213000);}
myMovie = new Movie (this, "WaitStill.mov");
delay(2000);
}
void movieEvent(Movie m) {
m.read();
}


AND (the only difference is that This one keeps the same variable for all the movies. That makes it super slow I think)
import processing.video.*;
Movie myMovie;
import processing.serial.*;
Serial port;
float getByte = -1;
float oldByte = 0;
float difference = 0;



void setup() {
size(screen.width, screen.height);
port = new Serial(this, Serial.list()[0], 9600);

}

void draw(){
image(myMovie, 0, 0);
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
getByte = port.read();
oldByte = getByte;
delay(40);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference > 200) {
myMovie.stop();
myMovie = new Movie (this, "CP1.mov");
myMovie.play();
delay(914000);}
else {
myMovie.loop();
exit();}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP2.mov");
myMovie.play();
delay(205000);}
else {
myMovie.stop();
myMovie = new Movie (this, "Where1.mov");
myMovie.play();
delay(205000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP2.mov");
myMovie.play();
delay (205000);}}
oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP3.mov");
myMovie.play();
delay(609000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where3.mov");
myMovie.play();
delay(327000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else{
myMovie.stop();
myMovie = new Movie(this, "CP3.mov");
delay(609000);}}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP4.mov");
myMovie.play();
delay(708000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Wait.mov");
myMovie.play();
delay(118000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP4.mov");
myMovie.play();
delay(708000);}}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP5.mov");
myMovie.play();
delay(109200);}
else{
myMovie.stop();
myMovie = new Movie (this, "Wait.mov");
myMovie.play();
delay(118000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP5.mov");
myMovie.play();
delay(109200);}}

delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP6.mov");
myMovie.play();
delay(813000);}
else{
myMovie.stop();
myMovie = new Movie (this, "WasTalking.mov");
myMovie.play();
delay(305000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP6.mov");
myMovie.play();
delay(813000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut1.mov");
myMovie.play();
delay(914000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where2.mov");
myMovie.play();
delay(2260);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut1.mov");
myMovie.play();
delay(914000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut2.mov");
myMovie.play();
delay(115000);}
else{
myMovie.stop();
myMovie = new Movie (this, "IDontKnow.mov");
myMovie.play();
delay(320000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut2.mov");
myMovie.play();
delay(115000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut3.mov");
myMovie.play();
delay(99100);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where1.mov");
myMovie.play();
delay(205000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut3.mov");
myMovie.play();
delay(99100);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "FuckOff.mov");
myMovie.play();
delay(213000);}
else{
myMovie.stop();
myMovie = new Movie (this, "FuckOff.mov");
myMovie.play();
delay(213000);}
myMovie = new Movie (this, "WaitStill.mov");
delay(2000);
}
void movieEvent(Movie m) {
m.read();
}

I know that the image/screen setting are not consistent or good in these pieces of code. I have been playing around with those in my sample code and still can't get what I want.

No comments: