Creating an array with movie files, and shuffling it.

Hey everyone,

I'm creating a movie player program with an Arduino board. I've successfully made the program play one movie file when I wave my hand in front of the Arduino PIR monitor, I just want it to randomly select from an array of other video files. Any help would be appreciated.

Here's my code so far...

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

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph, original 1
float inByte = 0;

String[] movieNames = { "1.mpg", "2.mpg", "3.mpg", "4.mpg"};
Movie[] movee = new Movie[movieNames.length];

void setup() {
  fullScreen();
  background(0);

  myPort = new Serial (this, "COM6", 9600);
  myPort.bufferUntil('\n');

  for (int i=0; i<movieNames.length; i++) {
    movee[i] = new Movie(this, movieNames[i]);
  }
}

void draw() {

  for (int i = 0; i < movieNames.length; i++) {
    image(movee[0], 0, 0);
  }
}

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

void serialEvent(Serial myPort) {
  String inString = myPort.readStringUntil('\n');

  if (inString != null) {
    inString = trim(inString);
    inByte = float(inString);

    println(inByte);

    if (inByte == 1) {
      movee[0].stop();
      println("Playing video...");
      movee[0].play();
    }

  }

}

Answers

Sign In or Register to comment.