Video library: why does read() need to be written as a statement in a function?

edited November 2015 in Library Questions

I've been learning how to use the video library, and I noticed that when you write

     myMovie.read();

by itself and not as a statement in a function (as in the code below), then the playback is jittery. I wondered if someone could explain why that is.

import processing.video.*;
Movie myMovie; 

void setup() {
  size(624, 352);
  myMovie = new Movie(this, "1.mp4");
  myMovie.loop();
}

void draw() {
  if (myMovie.available() == true) { 
     myMovie.read();
} 
  image(myMovie, 0, 0);      
}

Answers

  • edited November 2015
    • You mean w/o 1st checking whether a new frame is available()?
    • Remember that draw() is called back @ ~60 FPS.
    • And method read() copies the actual Movie's buffer into pixels[].
    • Moreover, read() is synchronized. It means while it's being executed, it also halts Movie.
    • IMO, it's more "comfortable" to place read() inside movieEvent() than checking for available() all the time inside draw().
Sign In or Register to comment.