Toggling between two videos in array with GLvideo

edited October 2017 in Raspberry PI

need a bit of help with this code. I'm trying to adapt a sketch I made originally for my laptop with the video library. It's pretty simple, I'm reading the values 1 and 0 from the serial port and switching between two synched clips each time there's a change. I'm not having such successful results trying to recreate this with GLVideo however, which I've never used before. hopefully I can fairly easily achieve what I want?

thanks for any help you might have

 import processing.serial.*;
 Serial myPort;
 int val=0;
 import gohai.glvideo.*;
 GLMovie[]video = new GLMovie [2];
 int i =0;

 void setup() {
   fullScreen(P2D);
   String portName = Serial.list()[0];
   myPort= new Serial (this, portName,115200);
   video [0] = new GLMovie(this, "low.mp4");
   video [1] = new GLMovie (this, "high.mp4");
   video [i].loop(); 
 }

 void draw() {
  image(video[i],0,0,width,height); 
  if (video[i].available()) {
     video[i].read(); 
   }
 } 
   void serialEvent(Serial p) {
     if (myPort.available()>0) {
       val=myPort.read();
       println(val); 
 }
 if (val==0) {
   i=1;
 }
 else {
   i=0;
 }
   }

Answers

Sign In or Register to comment.