Help with text and video

/**
 * Hacked Movie isPlaying() (v1.0)
 * GoToLoop (2018/Jul/28)
 * Discourse.Processing.org/t/help-with-text-and-video/2104/9
 */

import processing.video.Movie;
Movie vid;

void setup() {
  frameRate(30);
  textSize(050);
  textAlign(CENTER, BASELINE);
  fill(#FFFF00);

  vid = new Movie(this, "transit.mov") {
    @Override public boolean hasBufferSink() {
      return playing;
    }
  };

  vid.play();
  while (vid.width == 0 | vid.height == 0)  delay(10);

  getSurface().setSize(vid.width, vid.height); // P3
  //size(vid.width, vid.height); // P2
}

void draw() {
  if (vid.hasBufferSink())  background(vid);
  else {
    background((color) random(#000000));
    text("Playback has finished!", width>>1, height>>1);
  }
}

void movieEvent(final Movie m) {
  m.read();
}
2 Likes