processing / processing-video

GStreamer-based video library for Processing
276 stars 130 forks source link

processing about video playing and reverse playing issue #170

Open yoongangmin opened 3 years ago

yoongangmin commented 3 years ago

If run the code below, the video plays fine at first. If press the keyboard '2', it plays in reverse, and if press the keyboard '1', it plays. However, when I press '1' after press '2', the video runs a little and then stops :( what is the problem?

codes

import processing.video.*;

Movie myMovie; float playSpeed = 1.0;

void setup() { size(1920, 1080); frameRate(60); myMovie = new Movie(this, "test.mp4"); myMovie.play(); }

void movieEvent(Movie movie) { movie.read(); }

void draw() { background(0); image(myMovie, 0,0, width, height); myMovie.speed(playSpeed);

if(myMovie.time() > myMovie.duration()){ myMovie.stop(); myMovie.jump(myMovie.duration()); myMovie.stop(); } if(myMovie.time() < 0){ myMovie.jump(0); myMovie.stop(); } }

void keyPressed(){ if (key == '1'){ // keyPressed 1 = play playSpeed = 1.0; myMovie.play(); }

if (key == '2'){ // keyPressed 2 = playback playSpeed = -1.0; myMovie.play(); } }