import processing.serial.*; import gohai.glvideo.*; GLMovie mov; Serial myPort; int position = 0; float clipSec = 150; int linefeed = 10; // Linefeed in ASCII String inputString[]; // array to read the 4 values void setup() { size(1920, 1080, P3D); myPort = new Serial(this, "/dev/ttyUSB0", 9600); myPort.bufferUntil(linefeed); background(0); mov = new GLMovie(this, "SweetBox.mp4"); mov.loop(); mov.jump(0); } void draw() { background(0); if (mov.available()) { mov.read(); } image(mov, 0, 0, width, height); fill(255); text(mov.time(), 10, 30); if(mov.time()>=(position*clipSec)+clipSec){ position=0; mov.jump(0); mov.play(); } } void serialEvent(Serial myPort) { // read the serial buffer: String myString = myPort.readStringUntil(linefeed); // if you got any bytes other than the linefeed: if (myString != null) { myString = trim(myString); // split the string at the commas inputString = split(myString, '\t'); //println(inputString[1]); if(inputString[1]!=null){ position=int(inputString[1]); println(position); mov.jump(position*clipSec); mov.play(); } } } void keyPressed() { position=keyCode-48; mov.jump(position*clipSec); mov.play(); }