Help figuring out error when using Video library

edited December 2017 in Library Questions

This is my code that is currently used to cycle through 3 different videos by pressing Q:

import processing.video.*;
static final int movieCount = 3;
final Movie[] myMovie = new Movie[movieCount];
int index;
int maxMovieIndex = movieCount-1;

void setup() {
  size(1920, 1080);
  myMovie[0] = new Movie(this, "scene_0.mp4");
  myMovie[1] = new Movie(this, "scene_1.mp4");
  myMovie[2] = new Movie(this, "scene_2.mp4");
  myMovie[0].loop();
}

void draw() {
  set(0, 0, myMovie[index]);
  image(myMovie[index], 0, 0);

  println("index: " + index);
}

void keyPressed()
{
 if (key == 'q')
 {
   myMovie[index].pause();
   if (index != maxMovieIndex)
   {
    index++; 
   }
   else
   {
    index = 0; 
   }
   myMovie[index].loop();
 }
}

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

It runs, but if I exit after doing a switch, I get an error in the console upon exit:

(java.exe:6620): GStreamer-CRITICAL **: Trying to dispose element Movie Player, but it is in PAUSED instead of the NULL state. You need to explicitly set elements to the NULL state before dropping the final reference, to allow them to clean up. This problem may also be caused by a refcounting bug in the application or some element.

(java.exe:6620): GStreamer-CRITICAL **: Trying to dispose element inputselector0, but it is in PAUSED instead of the NULL state. You need to explicitly set elements to the NULL state before dropping the final reference, to allow them to clean up. This problem may also be caused by a refcounting bug in the application or some element.

What does this mean, and how do I fix it? I guess it has to do with how the Movie object is used, but I haven't seen examples in the documentation on why/how to safely exit.

Answers

  • edited December 2017

    That exit() glitch happens b/c there are some pause() Movie.
    You may @Override the exit() in order to stop() or dispose() them all in a loop: *-:)

    @Override void exit() {
      for (final Movie mov : movies)  mov.stop();
      super.exit();
    }
    
  • Remove line 16... not needed.

    Instead of pause, use stop in line 26. However, you need to instantiate the object myMovie[i] = new Movie(this, "..."); before you call line 35. You need to implement that part.

    Kf

  • I've added the exit override and stop. It works well from what I can tell (though I got an out of bounds 0 error exactly once, and I haven't been able to reproduce that outcome).

    Could you please explain the instantiate part more? Are lines 3, 9, 10, and 11 not sufficient? Thanks!

  • If you stop a movie, from my experience, it is not guaranteed it is available next time you call play/loop. I might be wrong...

    Kf

Sign In or Register to comment.