How do I tell if a GLMovie is done playing?

I'm having a hard time figuring out when a GLMovie is done playing.

Here's my code, a very slightly modified version of the "SingleVideo" example from the GL Video library:

import gohai.glvideo.*;
GLMovie video;

void setup() {
  size(560, 406, P2D);
  video = new GLMovie(this, "launch1.mp4");

  video.play();
}

void draw() {
  background(0);
  if (video.available()) {
    video.read();
    println(video.time() + " of " + video.duration());
    // e.g. 14.951508 of 14.981999 when done
    if(video.time() >= video.duration()){
      println("Done playing."); // This never happens.
    }
  }
  image(video, 0, 0, width, height);
}

So the video time never actually reaches the duration - and anyway it would be nice to attach to some kind of event, rather than checking manually every frame.

I tried the solution posted here: https://forum.processing.org/two/discussion/14990/movie-begin-and-end-events#Item_1

But apparently the eosEvent function doesn't exist in the GL Video library.

Anyone know of an equivalent? Or maybe another solution to this problem?

Thanks in advance.

Answers

Sign In or Register to comment.