We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Well, hello, first of all, I'm new in Java and processing (just few months learning). I have a problem with the video, it doesn't load. I've created three string, they work but the video looks like a photo, it doesn't play. I've tried to change the resolution of the video (it's so low right now; codecs: H.264, AAC, dimension: 720 × 576, 25fg edited by Adobe Premiere, ), I can't find the mistake. I will be gratefull if someone could answer, thank you.
import processing.video.*;
String[] one = {"0.mov","5.mov"};
String[] two = {"8.mov", "4.mov"};
String[] three = {"9.mov", "2.mov"};
Movie myMovie;
void setup()
{
size(720,540);
background(0);
}
void movieEvent(Movie m) {
m.read();
}
void draw()
{
}
void keyPressed()
{
if( key == 'a' || key == 'A'){
myMovie = new Movie(this, one[int(random(one.length))]);
myMovie.play();
myMovie.noLoop();
image(myMovie, 0, 0);
}
else if( key == 's' || key == 'S'){
myMovie = new Movie(this, two[int(random(two.length))]);
myMovie.play();
myMovie.noLoop();
image(myMovie, 0, 0);
}
else if( key == 'd' || key == 'D') {
myMovie = new Movie(this, three[int(random(three.length))]);
myMovie.play();
myMovie.noLoop();
image(myMovie, 0, 0);
}
}
Answers
image(myMovie) must be in draw(), otherwise it will be called only when you press a key.
See the video examples shipped with Processing.
I tried too, but the image shows a background(0), and it get's me a mistake in "image(myMovie)" when it's in void draw. I cannot understand why. Thanks for answers PhiLho :)
Show the other version.
And when you get a "mistake" (we prefer to talk about error messages), you should report them fully (copy / paste their text).
Hi, PhiLho, I tried it again, "NullPointerException", I've search about this in internet, it says that maybe could be a problem with the video, but it's not the case. The video plays in another code, it's in the data folder too. Seriously, I can't understand, the code "works", at last it starts, but when I put "image(myMovie)" in another place, NullPointerException appears. Thank you so much for the initiative.
"Show the other version."...
But now I guess what is wrong: you must initialize myMovie with at least one Movie instance, in setup().
But if I initialize myMovie in void setup, the video get's a loop, the video plays and when I press the key, plays too, at the same time. (The versión it's exactly but image(myMovie) in void draw.
Then do:
to prevent the NPE.
Thank you so much, PhiLho :)