import processing.video.*;
void draw()
{
background(0);
image(videos[current], 0, 0, width- 1, height-1);
if(videos[current].time()%10 > 9.5)
{
int newAd = int(random(0, lengths[current]-9));
newAd -= newAd%10; //% – modulus
videos[current].jump(newAd);
}
//println(videos[current]);
}
void movieEvent(Movie m) {
m.read();
println(m);
}
void remoteInput()
{
if(inByte >= ‘0’ && inByte <= ‘9’)
{
command = command + inByte;
}
else if(inByte == 10)
{
println(command);
int commandInt = Integer.parseInt(command);
if (commandInt >= 1 && commandInt <= 7)
{
videos[current].stop();
videos[current].jump(0);
current = commandInt-1;
int newAd = int(random(0, lengths[current]-9));
newAd -= newAd%10; //% – modulus
videos[current].jump(newAd);
videos[current].play();
}
else if (command.equals(“12”))
{
exit();
}
//else if( … )
// {
// …
//}
command = “”;
}
}
void serialEvent(Serial myPort)
{
if(myPort.available() > 0)
{
inByte = myPort.readChar();
}
remoteInput();
}
import processing.serial.*;
import processing.video.*;
Serial myPort; // The serial port:
int current = 0;
float f;
float movSpeed;
String command;
char inByte;
Movie[] videos;
int[] lengths;
void setup()
{
size(720, 576);
background(0);
videos = new Movie[7];
lengths = new int[7];
videos[0] = new Movie(this, “gida.mov”);
videos[1] = new Movie(this, “oto.mov”);
videos[2] = new Movie(this, “cocuk.mov”);
videos[3] = new Movie(this, “aile.mov”);
videos[4] = new Movie(this, “seks.mov”);
videos[5] = new Movie(this, “kirmizi.mov”);
videos[6] = new Movie(this, “animasyon.mov”);
for(int i = 0; i<videos.length; i++)
{
videos[i].stop();
videos[i].jump(0);
lengths[i] = int(videos[i].duration());
}
videos[current].play();
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
command = “”;
inByte = ‘ ‘;
}