processing / processing-video

GStreamer-based video library for Processing
274 stars 130 forks source link

Problem using try-catch structure with video lib #146

Open Real-John-Cheung opened 4 years ago

Real-John-Cheung commented 4 years ago

Environment: macOS Catalina 10.15.3; Processing 3.5.4 ; Video2 lib beta release 4 Problem: I try to use a try-catch structure to load video like this

import processing.video.*;
Movie m;
boolean error = false;
void setup(){
  size(200,200);
}

void draw(){
  background(0);
  if (error){
    background(255,0,0);
  }
}

void keyPressed(){
  if (key == 'h'){
    String tem= key+".mp4";
    try{
      m = new Movie (this,tem);
    }
    catch (Exception e){
      error = true;
      m = null;
      loop();
      print("catch is run");
    }
  }
}

I put not thing in the folder so there should alway be an exception, what happen is the code in catch would be run once and the whole sketch just frozen. I have used similar code to load image(doesn't require any library) and it worked well. So I think there maybe problems with the video library.

edit: when the file name is correct it can be loaded use the code above.