Hi,
I am trying to get a random video to play from an array but a selected number only for when I press the left or right click. For this I created two seperate variables to generate a random number. Every time I click left it seems to be working yet it is glitching. I don’t think I am going about it the right way either…I can’t quite understand what I am doing wrong.
Any help will be appreciated.
import processing.video.*;
Movie myMovie3;
Movie[] mov = new Movie [8];
final static int IDLE = 1;
final static int ANIM1 = 2;
final static int ANIM2 = 3;
int state = 1;
int count = 0;
int rIndex; //variable for random R poster to display - 6 videos 
int gIndex; //variable for random G poster to display - only two videos 
void setup() {
  size(405, 720);
  for (int i = 0; i < mov.length; i ++) {
    mov[i] = new Movie(this, "mov"+i+".mp4");
  }
  myMovie3 = new Movie(this, "background.mov"); // background video
  myMovie3.loop();
}
void movieEvent(Movie m) {
  m.read();
}
void draw() {
  background(0);
  rIndex = int(random(2, 8));
  gIndex = int(random(0, 2));
  if (state == IDLE) {
    image(myMovie3, 0, 0, width, height);
    textSize(26);
    text("Count Variable: " + count, 130, 50);
  } else if (state == ANIM1) {
    for (int i = 0; i < mov.length; i++) {
      image(mov[rIndex], 0, 0, width, height);
      if (mov[rIndex].time() >= 6.0) state = IDLE;
    }
  } else if (state == ANIM2) {
    for (int i = 0; i < mov.length; i++) {
      image(mov[gIndex], 0, 0, width, height);
      if (mov[gIndex].time() >= 10.0) state = IDLE;
    }
  }
}
void mousePressed() {
  if (mouseButton == LEFT) { 
    state = ANIM1;
    mov[rIndex].jump(0.0);
    mov[rIndex].play();
    count = count + 5;
  } else if (mouseButton == RIGHT) {
    state = ANIM2;
    mov[gIndex].jump(0.0);
    mov[gIndex].play();
    count -= 3;
  } else state = IDLE;
}
Thanks in advance!
 Thanks heaps! but  I changed it to being
 Thanks heaps! but  I changed it to being