Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Random video player freezes after two hours

$
0
0

Hi everybody

For a project I programmed a random video player using the processing video library. If the space bar is pressed a random video is played. After that the player plays a video in a loop until space bar is pressed again. This worked perfectly on my MacBook, however it doesn't in the installation setting with a slightly older iMac. I guess the source for the problem lies in the code. But I cannot figure out were.

Any help is very welcome.

This is the code:

import processing.video.*;

int numMovies = 9;
boolean valid=false;
String[] one = {
  "Video1.mp4", "Video2.mp4", "Video3.mp4", "Video4.mp4", "Video5.mp4", "Video6.mp4", "Video7.mp4", "Video8.mp4", "Video9.mp4"
};

float movieEndDuration = 0.5;

Movie myMovie;
Movie myLoop;

void setup()
{
  fullScreen(P2D);
  myLoop  = new Movie(this, "VideoLoop.mp4");
  myLoop.loop();
}

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


void draw()
{
  if (valid == true) {
    image(myMovie, 0, 0, width, height);
  } else
  {
    image(myLoop, 0, 0, width, height);
  }
  if (valid && myMovie.time()+ movieEndDuration >= myMovie.duration()) {
    myMovie.stop();
    valid=false;
    myLoop = new Movie(this, "VideoLoop.mp4");
    myLoop.loop();
  }
}


void keyPressed() {
  if (key == ' ' && valid==true) {
    myMovie.stop();
    myLoop.stop();
  }
  if (keyCode == ENTER && valid==true)
  {
    myMovie.stop();
    myLoop.stop();
  }
}


void keyReleased()
{

  if (key == ' ')
  {
    valid=true;
    println(one[int(random(numMovies))]);
    myLoop.stop();
    myMovie = new Movie(this, one[int(random(numMovies))]);
    myMovie.play();
  }
  if (keyCode == ENTER)
  {
    valid=true;
    myLoop.stop();
    myMovie = new Movie(this, "About.mp4");
    myMovie.play();
  }
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles