Video won't play; causes black screen

edited June 2014 in Library Questions

Hello there. I've been trying to get back into Processing a bit for a project (haven't used it about 2 years) and am trying to reappropriate some old code that I know previously worked, but can't for the life of me figure out why it won't work now.

I'm trying to use video in a Processing sketch attached to a switch case statement. That being said, when I tell Processing to play the video, I get nothing but a black screen/application with nothing playing. I've been experimenting with different videos that have worked for sure in the past both in mp4 and mov formats but both produce nothing, however the audio seems to play if it has audio for some odd reason. I have confirmed through print statements that it is switching however it's still showing nothing and I can't figure out why. At one point recently it's also begun giving me Array Index Out of Bounds Exceptions for no reason at random times. I'll post the code here, however, it should be noted that I'm using Processing 1.5.1 because I know from experience before I quit Processing that Processing 2.0 causes a whole bunch of past projects to break due to differences. Here's the code.

import processing.video.*;

Movie test1;
Movie test2;

int bg = 0;
int action = 0;

void setup () {
  size (900,900);
  test1 = new Movie(this, "myTree.mp4");
  test2 = new Movie(this, "myEyes.mp4"); 
}

void draw () {
  background (255);

  if (mousePressed){
    action++;
  }
if (action == 2) {
  action = 0;
}

switch (action) {
  case 0:
    image(test1, 0,0,0,0);
    println("testONNNO");
    break;
  case 1:
    image(test2, 0, 0);
    println("testTWWOOOO");
    break;
}

}

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

Answers

  • One thing that strikes me as odd is line 27:

        image(test1, 0,0,0,0);
    

    From the image() reference, you will see that having the third and fourth parameters sets the size of the image - in this case, to (0, 0). I doubt this will since your problem, but it's probably worth pointing out.

  • if (play_movie) { myMovie.play(); if (myMovie.available()) { myMovie.read(); } image(myMovie, 0, 0, 1366, 768); float md = myMovie.duration(); float mt = myMovie.time(); if (mt > md-1) { myMovie.stop(); play_movie=false; } you have read but no play :) available checks if you can upload the next frame and play plays it. the mt/md stuff stops a movie from playing if it is finished

Sign In or Register to comment.