We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am wondering how to read a movie file inside of draw()?
The example https://processing.org/reference/libraries/video/Movie.html reads the file inside of setup()
I want to be able to change what movie is being played while the sketch is running. I.e. use the up and down arrows to cycle through some videos in a folder. If the movie's location is assigned in setup() it cannot be changed once running.
For instance, if I try to use movie in the draw() it runs INCREDIBLY SLOW. As would be expected since it is creating a fresh movie object each frame.
import processing.video.*;
Movie myMovie;
File dir = new File("/Applications/SimplMix/ProcessingFork/vidz");
File[] fileArr = dir.listFiles();
void setup() {
size(1280, 720);
}
void draw() {
myMovie = new Movie(this, "/Applications/SimplMix/ProcessingFork/vidz/NewFall.mov");
myMovie.loop();
myMovie.play();
image(myMovie, 0, 0);
}
void movieEvent(Movie m) {
m.read();
}
Answers
Well this seams to work:
But I would prefer to load all my videos at setup, in an array and just change the index, like:
I like to even turn off draw() w/ noLoop(). And use redraw() inside movieEvent().
Also I find background() & set() faster than image() for JAVA2D renderer:
http://forum.processing.org/two/discussion/comment/40848/#Comment_40848
I look forward to exploring both these possibilities on the plane - thank you for the ideas.
@_vk I like the idea in the second example. I am trying to have the option for a user to add more videos to the folder and then restart (in an ideal world no restart needed the array could be refreshed).
Is there a way to have only one movie object that has a new file path loaded from this array? I think it may be possible. Once again, I'll have to hack around.