We are about to switch to a new forum software. Until then we have removed the registration on this forum.
The code below is another test of my Electronic Art Proyect.
I've tried if you press a key, one of these videos (random) plays and displays in the draw, but, I don't know what I can do to choose four videos to each key.
Nobody knows why the video plays so slowly? codecs? JAVA?..
Thanks :)
//Display 0 does not exist, using the default display instead. ¿?
import processing.video.*;
String[] one = {
"ag1.mov", "ag2.mov", "ag3.mov", "am1.mov", "am2.mov", "am3.mov",
"tran1.mov", "tran2.mov", "tran3.mov"
};
Movie myMovie;
int a = 0;
float md = 0;
float mt = 0;
void setup()
{
size(400, 400, P2D);
}
void draw()
{
image(myMovie, 0, 0, width, height);
}
void keyPressed()
{
if (key == 'a' || key == 'A')
{
myMovie = new Movie(this, int(random(1, 3));
myMovie.play();
}
else if (key == 's' || key == 'S')
{
myMovie = new Movie(this, int(random(4, 6));
myMovie.play();
}
else if (key == 'd' || key == 'D')
{
myMovie = new Movie(this, int(random(7, 9));
myMovie.play();
}
else
{
myMovie.stop();
}
}
Answers
myMovie = new Movie(this, one[int(random(low, high)]);
You cannot play a number! You have to choose the file name from the array. Note that loading a video on the fly like this can be quite slow.
And you might need to stop and close the previous video before loading a new one.