Hi everyone, I'm new to Processing and I've been working on this video-art / installation project for my graduation.
My question is: How can I set a random video to be played next?
I managed to get the videos playing, but I can't set another random video to follow. My intention is to have a sequence of videos (maybe 10 or more) that will play in a shuffled order. I have looked around this and some other forums but couldn't find a specific answer. Hope you guys can help me out. Thanks!
ps. if something doesn't make sense in my code please tell me :)
import processing.video.*;
import processing.sound.*;
AudioIn input;
Amplitude analyzer;
int scale=4;
Movie mov1, mov2;
Capture cam;
int n = 5; //total number of videos
float vidN = random(1, n+1);
int x = int (vidN);
float vidN2 = random(1, n+1);
int x2 = int (vidN2);
void setup() {
//frameRate (30);
size(1280, 720);
colorMode (HSB);
//fullScreen();
//background(0);
mov1 = new Movie(this, nf(x, 2)+".mp4");
mov1.loop();
mov1.volume(100);
mov2 = new Movie(this, nf(x2, 2)+".mp4");
mov2.loop();
mov2.volume(00);
cam = new Capture(this, width, height);
cam.start();
blendMode(DIFFERENCE);
imageMode(CENTER);
//Create an Audio input and grab the 1st channel
input = new AudioIn(this, 0);
// start the Audio Input
input.start();
// create a new Amplitude analyzer
analyzer = new Amplitude(this);
// Patch the input to an volume analyzer
analyzer.input(input);
}
void movieEvent(Movie m) {
if (m == mov1) {
mov1.read();
} else if (m == mov2) {
mov2.read();
}
}
void draw() {
float vol = analyzer.analyze();
noStroke ();
tint (255, 80);
if (cam.available()) {
cam.read();
image(cam, width/2, height/2, width, height); // Draw the webcam cam onto the screen
vol = vol*scale;
tint (255, 100-vol*100);
image(mov1, width/2, height/2, width, height);
tint (255, 100-vol*100);
image(mov2, width/2, height/2, width, height);
}
}