playing 2 or more video files simultaneously

I want to overlay multiple video files (they're saved inside my data folder). I am able to load one successfully, but the moment I try more than one, all I hear is the audio and the video never loads. Below is some simplified code as an example that doesn't function for me:

import processing.video.*;

Movie vidFile1;
Movie vidFile2;

void setup()
{ 
  size(1920, 1080);
  background(0);


  vidFile1 = new Movie(this, "video1.mp4");
  vidFile1.loop();
  vidFile2 = new Movie(this, "video2.mp4");
  vidFile2.loop();
}

void movieEvent(Movie vidFile1, Movie vidFile2)
{
  vidFile1.read();
  vidFile2.read();
}

void draw()
{
  image(vidFile1,0,0);
  image(vidFile2,720,0);
}
Tagged:

Answers

  • Try changing movieEvent to:

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

    I believe it will be automatically called (by the library, while things are running) for both vidFile1 and vidFile2 separately, passing that object and calling its read() method -- you don't need to specify each movie in a separate parameter.

Sign In or Register to comment.