Audio plays but screen stays black

Here is my code, the scenario is opened from Arduino button. One button plays 1 and the other 2. The buttons and the printing work good. The screen opens, audio plays but the movie/frames don’t.

import processing.serial.*;
import processing.video.*;

Serial port;

PImage img1, img2;

Movie movie1, movie2;

void setup(){
  fullScreen();

  background(0);
  
  printArray(Serial.list()); //print alle serial poorten
 
  port = new Serial(this, "/dev/cu.SLAB_USBtoUART", 9600);
  
  img1 = loadImage("IMG_3147.jpg");
  
  img2 = loadImage("IMG_2395.JPG");

  newStart();

}

void movies(){
  movie1 = new Movie(this, "IMG_0585.mp4");

  movie1.loop();

  movie2 = new Movie(this, "IMG_0574.mp4");

  movie2.loop();
}

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

void newStart(){
  background(0);
}

void draw(){
     int scenario = port.read();
     println(scenario);
     
    if (scenario == 2) { 
      movies();
      movie1.play(); 
      if (movie1.available()) {
        movie1.read(); 
      }
      image(movie1, 0, 0, width, height);
    }
    
    if (scenario == 1) { 
      movies();
      movie2.play(); 
      if (movie2.available()) {
        movie2.read(); 
      }
      image(movie2, 0, 0, width, height);
    }
     
     if (scenario == -1){
       int lachen = 3;
       println(lachen);
       delay(100);
     }
}
 
1 Like

-a- loading movie files from draw ( in every draw loop ) is a bad idea
only in setup()

-b-
i think this is all the code you need in draw()

  if (scenario == 2)    image(movie1, 0, 0, width, height);
  if (scenario == 1)    image(movie2, 0, 0, width, height);

-c-

  • do not post code what can not run in fullscreen mode
  • clean up and take out all what is not needed to test your problem here
    • the arduino thing
      and change the category back to library )
      and state that you use the movie library you have have problems to use
    • the images we not have you load but not use
1 Like