Video does not show up when object oriented code runs

Hello Processors, thank you for your time. I made an object using another object called Movie, so that two videos appear floating upwards and stay in the top. The code runs but only the white background appears.

import processing.video.*;
Movie myMovie;
Video v1;
Video v2; 

void setup() {
  size(640, 360);
  myMovie = new Movie(this, "fogata.mp4");
  myMovie.loop();
  v1 = new Video(74);
  v2 = new Video(26);// this is calling the constructor
}

void draw() {
  background(255);
  v1.display();
  v1.ascend();
  v1.top();
  
  v2.display();
  v2.ascend();
  v2.top();
}


class Video {

  //data
  float x;
  float y;
  float size;

  Video(float tempD) {//here is where initialization starts
    x = width/2;
    y = height;
    size = tempD;

  }
  void ascend() {
    y--;
    x = x + random(-1, 1);
  }

  void top() {
    if (y < size/2) {
      y = size/2;
    }
  }
  
  //functuality: function definitions
  void display() {
    image(myMovie, x, y, size, size);
  }
}
1 Like

I’m not an expert on the video library, but don’t you need to read the video as it plays? Something like this:

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

YAAAS !! that was it, Thank you Kevin.

You’re very welcome.

For future reference, this info is usually in the reference pages for the library you’re using. In this case, I’d start here.

1 Like

is it okay if I make a different question regarding the same code (i added some line) in this same post?

It’s up to you. There aren’t any strict rules. If it’s about the same code it’s probably fine, but if it’s a different problem then a new post is probably best.

As long as you’re working from a small example program and not posting unrelated code, it should be fine either way.

1 Like