We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Well, I'm trying to display a random video with this code, but I want to know if I can use more String, and how I can write that.
There is another problem: the random video (2Mb, 720x576 resolution, coverted in Internet from .avi to .mov) play in Quicktime very faster than in Processing.
The question is... Is JAVA effective to play videos in PROCESSING?
import processing.video.*; String[] moviesNames = { "1.mov", "2.mov", "3.mov", "4.mov", "7.mov", "6.mov" }; int index = int(random(moviesNames.length));
int colore = 1;
int fondo = 0;
Movie[] movies;
void setup() {
size(640, 480, P2D);
movies = new Movie[moviesNames.length];
for (int i = 0; i < moviesNames.length; i++) {
movies[i] = new Movie(this, moviesNames[i]);
}
}
void draw() {
//background(fondo);
image(movies[index], 0, 0, width, height);
fill(0,0,0,fondo);
noStroke ();
rect(0, 0, width, height);
}
void movieEvent(Movie _mov) {
_mov.read();
}
void keyPressed() {
int k = keyCode;
if (k == 'Q') fondo=0; pickRandomVideoIndex();
if (k == 'A') {fondo = 255;}
}
void pickRandomVideoIndex() {
if (movies.length <= 1) return;
movies[index].pause(); // pause current video.
int rnd; // keep picking a new index till got a diff. 1:
while ( (rnd = (int) random(movies.length)) == index );
// assign newly picked random value to index:
movies[index = rnd].loop(); // and start playing it.
}
Answers
Got 3 tips below. See if you got any improvements:
size(640, 480, JAVA2D);
frameRate(25);
P.S.: Is that movieEvent() really necessary? Comment that callback function out! (~~)