Video switch not on Loop

I compiled this code from some sources and it works (what is a big deal) but my video stops after it plays and I would like it to play on loop. Tried loop(); function but didn’t work. Any suggestions?

import processing.video.*;
Movie theMov; 
int VideoPlaying;

int time;
boolean leftIsPressed, shiftIsPressed, rightIsPressed;
boolean keyAction;

// Step #1 : Enter Boolean + Vid + next number + =false; ================================================================
boolean Vid1 = false;
boolean Vid2 = false;
boolean Vid3 = false;
boolean Vid4 = false;
boolean Vid5 = false;

// Step #2 : Create new Movie + Video + _next number; ================================================================
Movie Video_01; 
Movie Video_02; 
Movie Video_03;
Movie Video_04;
Movie Video_05;


void setup() { // Step #3 : Create new entry with "Video_Number" = new Movie(this, "NAME OF VIDEO.MOV"); } ================================================================
  size(displayWidth, displayHeight);
    //fullScreen();
  time = millis();
  Video_01 = new Movie(this, "test1.mov");
  Video_02 = new Movie(this, "test2.mp4");
  Video_03 = new Movie(this, "test3.mov");
  Video_04 = new Movie(this, "test4.mov");
  Video_05 = new Movie(this, "test5.mov");
}

void draw() { // Step #4 : Enter new (VidNEXTNUMBER) with { video_number of Step #3 }; ================================================================
  background(0);
  fill(255);
  textSize(100);
    textAlign(CENTER, CENTER);
  text("START VIDEO BY PRESSING ANY KEY", 0, 0, width, height);

  toogle();
  if (Vid1) {
    video_01();
  }
  if (Vid2) {
    video_02();
  }
  if (Vid3) {
    video_03();
  }
  if (Vid4) {
    video_04();
  }
  if (Vid5) {
    video_05();
  }
}

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

void keyPressed() { // Step #5 : Create new entry as : if (key == NEW_KEY { VideoPlaying = NUMBER_SAMEAS_VIDEO_NUMBER; println(Videoplaying);} ================================================================
  
  if (key == ESC) {
    key = 0;  // ESCAPE doesn't close the sketch.
  }

  if (key == 'a') { // Video 01
    VideoPlaying = 1 ;
    println(VideoPlaying);
  }
  if (key == 'z') { // Video 02
    VideoPlaying = 2 ;
    println(VideoPlaying);
  }
  if (key == 'e') { // Video 03
    VideoPlaying = 3 ;
    println(VideoPlaying);
  }
  if (key == 'r') { // Video 04
    VideoPlaying = 4 ;
    println(VideoPlaying);
  }
  if (key == ENTER) { // Video 04
    VideoPlaying = 5 ;
    println(VideoPlaying);
  }
}



void video_01() { // Step #6 : Create new entry as : void video_NEXTNUMBER() { println("VideoNUMBER"); all other Video_XX.stop(); background(O); Video_NEWNUMBER(); background(0); image()Video_NEWNUMBER, 0, 0, width, height);} ================================================================
println("time");
  println("video1");
  Video_02.stop();
  Video_03.stop(); 
  Video_04.stop();
    Video_05.stop();
  background(0);
  Video_01.play();
  background(0);
  image(Video_01, 0, 0, width, height);
}
void video_02() {
  println("video2");
  Video_01.stop();
  Video_03.stop(); 
  Video_04.stop();
    Video_05.stop();
  background(0);
  Video_02.play();
  image(Video_02, 0, 0, width, height);
}
void video_03() {
  println("video3");
  Video_01.stop();
  Video_02.stop();
  Video_04.stop();
    Video_05.stop();
  background(0);
  Video_03.play();
  image(Video_03, 0, 0, width, height);
}
void video_04() {
  println("video4");
  Video_01.stop();
  Video_02.stop();
  Video_03.stop();
  Video_05.stop();
  background(0);
  Video_04.play();
  image(Video_04, 0, 0, width, height);
}
void video_05() {
  println("video5");
  Video_01.stop();
  Video_02.stop();
  Video_03.stop();
  Video_04.stop();
  background(0);
  Video_05.play();
  image(Video_05, 0, 0, width, height);
}

void toogle() { // Step #7 : Create new entry as : if (VideoPlaying == NEWNUMBER) { Complete list of all "VIDx = false" + "VID_NEWNUMBER = true" }; ================================================================
  if (VideoPlaying == 1) {
    Vid1 = true;
    Vid2 = false;
    Vid3 = false;
    Vid4 = false;
    Vid5 = false;
  }

  if (VideoPlaying == 2) {
    Vid1 = false;
    Vid2 = true;
    Vid3 = false;
    Vid4 = false;
    Vid5 = false;

  }

  if (VideoPlaying == 3) {
    Vid1 = false;
    Vid2 = false;
    Vid3 = true;
    Vid4 = false;
    Vid5 = false;
  }

  if (VideoPlaying == 4) {
    Vid1 = false;
    Vid2 = false;
    Vid3 = false;
    Vid4 = true;
    Vid5 = false;
  }
  
  if (VideoPlaying == 5) {
    Vid1 = false;
    Vid2 = false;
    Vid3 = false;
    Vid4 = false;
    Vid5 = true;
  }
}
1 Like

Simply write .loop() :

void video_01() { println("time");
  println("video1");
  background(0); //  this is not necessary
  Video_01.loop(); // ======= HERE
  background(0); //  this is not necessary
  image(Video_01, 0, 0, width, height);
}

It works for me

1 Like