diff --git a/java/libraries/video/examples/Movie/Frames/Frames.pde b/java/libraries/video/examples/Movie/Frames/Frames.pde index 69c9ff7a5..511f4800a 100644 --- a/java/libraries/video/examples/Movie/Frames/Frames.pde +++ b/java/libraries/video/examples/Movie/Frames/Frames.pde @@ -20,7 +20,11 @@ void setup() { // and we can get duration, size and other information from // the video stream. movie = new Movie(this, "station.mov"); + + // Pausing the video at the first frame. movie.play(); + movie.goToBeginning(); + movie.pause(); font = loadFont("DejaVuSans-24.vlw"); textFont(font, 24); @@ -31,15 +35,9 @@ void movieEvent(Movie movie) { } void draw() { - if (newFrame != movie.frame()) { - // The movie stream must be in play mode in order to jump to another - // position along the stream. Otherwise it won't work. - movie.play(); - movie.jump(newFrame); - movie.pause(); - } image(movie, 0, 0, width, height); fill(240, 20, 30); + text(movie.frame() + " / " + (movie.length() - 1), 10, 30); } @@ -51,4 +49,8 @@ void keyPressed() { if (newFrame < movie.length() - 1) newFrame++; } } + + movie.play(); + movie.jump(newFrame); + movie.pause(); } diff --git a/java/libraries/video/examples/Movie/Reverse/Reverse.pde b/java/libraries/video/examples/Movie/Reverse/Reverse.pde index 4928dcd47..09cc41136 100644 --- a/java/libraries/video/examples/Movie/Reverse/Reverse.pde +++ b/java/libraries/video/examples/Movie/Reverse/Reverse.pde @@ -36,9 +36,12 @@ public void draw() { // this is the reason for the if statement. speedSet = true; myMovie.goToEnd(); - // -1 means backward playback at normal speed, + // -1 means backward playback at normal speed. myMovie.speed(-1.0); + // Setting to play again, since the movie stop + // playback once it reached the end. + myMovie.play(); } } image(myMovie, 0, 0, width, height); -} +} \ No newline at end of file diff --git a/java/libraries/video/examples/Movie/Scratch/Scratch.pde b/java/libraries/video/examples/Movie/Scratch/Scratch.pde index 2ca65618a..513b4dc60 100644 --- a/java/libraries/video/examples/Movie/Scratch/Scratch.pde +++ b/java/libraries/video/examples/Movie/Scratch/Scratch.pde @@ -13,12 +13,13 @@ Movie movie; void setup() { size(640, 480); background(0); - // Load and set the video to play. Setting the video - // in play mode is needed so at least one frame is read - // and we can get duration, size and other information from - // the video stream. + movie = new Movie(this, "station.mov"); + + // Pausing the video at the first frame. movie.play(); + movie.goToBeginning(); + movie.pause(); } void movieEvent(Movie movie) { @@ -28,22 +29,11 @@ void movieEvent(Movie movie) { void draw() { // A new time position is calculated using the current mouse location: float f = constrain((float)mouseX / width, 0, 1); - float t = movie.duration() * f; - - // If the new time is different enough from the current position, - // then we jump to the new position. But how different? Here the - // difference has been set to 0.1 (1 tenth of a second), but it can - // be smaller. My guess is that the smallest value should correspond - // to the duration of a single frame (for instance 1/24 if the frame rate - // of the video file is 24fps). Setting even smaller values seem to lead - // to choppiness. This will become trickier once the Movie.speed() - // and Movie.frameRate() methods become functional. - if (0.1 < abs(t - movie.time())) { - // The movie stream must be in play mode in order to jump to another - // position along the stream. Otherwise it won't work. + float t = movie.duration() * f; + if (movie.ready()) { movie.play(); movie.jump(t); movie.pause(); - } + } image(movie, 0, 0, width, height); -} +} \ No newline at end of file