I'm currently in the process of making a code that will pull three random videos when a key is pressed.
For example, when the "A" key is pressed the code will randomly select one of three video files assigned to that key and play.
However, the problem at the moment is when I run the sketch I get the error "Could not load movie file 2" on the code line 35
-
myMovie = new Movie(this, ""+int(random(1, 3)));
and the same for 1 and 3. I have made it so the sketch would play each video individually to see if it was a problem with the video files but it still couldn't find any of the files. The videos were imported through Sketch and Add file and they are found in the sketchbook file under data.
If anyone could help out I would greatly appreciate it, thank you. :)
import processing.video.*;
boolean valid=false;
String[] one = {
"1.mp4", "2.mp4", "3.mov", "4.mov", "5.mov", "6.mov", "7.mov",
"8.mov", "9.mov" };
Movie myMovie;
int a = 0;
float md = 0;
float mt = 0;
void setup() {
size(400, 400, P2D);
}
void draw()
{
if (valid){
image(myMovie, 0, 0, width, height);
}
}
void keyPressed()
{
if (key == 'a' || key == 'A')
{
valid=true;
myMovie = new Movie(this, ""+int(random(1, 3)));
myMovie.play(); }
else if (key == 's' || key == 'S')
{
valid=true;
myMovie = new Movie(this, ""+int(random(4, 6)));
myMovie.play(); }
else if (key == 'd' || key == 'D')
{
valid=true;
myMovie = new Movie(this, ""+int(random(7, 9)));
myMovie.play(); }
else
{
myMovie.stop(); }
}
my apologise for the layout of the code I was unsure how to properly copy and paste the code into this comment.
Aucun commentaire:
Enregistrer un commentaire