Movie file doesn't load

Hi

I’m trying to create an array of objects
Each object contains some variables and a movie object
For some reason, when calling on the movies duration() I’m getting information that doesn’t make sense (shows as 0.0), and the movies don’t play

import processing.video.*;


Table table;

class clip{
  String fileName;
  int clipNumber;
  String type;
  float clipDuration;
  Movie movieObject;
  
  //function to assign data from new clip
  clip(String fileName_, int clipNumber_){
    fileName = fileName_;
    clipNumber = clipNumber_; 
  }
}

clip[] clips;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


void setup() {
  size(640, 360);
  background(0);
  
  loadData();
  
  //verify that clips were loaded into array
  for(clip A : clips){
    print(A.fileName, " ");
    println(A.clipDuration);
  }
  
  
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void draw() {    
  image(clips[1].movieObject, 0, 0);
}  

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void loadData() {
  table = loadTable("EPIGEN_data.csv", "header");

  clips = new clip[table.getRowCount()]; 

  int rowCount = 0;
  for (TableRow row : table.rows()) {
    
    String temp_fileName = row.getString("title");
    int temp_clipNumber = row.getInt("index");
    
    clips[rowCount] = new clip(temp_fileName, temp_clipNumber);
    clips[rowCount].movieObject = new Movie(this, temp_fileName);
    tempMov = new Movie(this, temp_fileName);
    println(tempMov.duration(), "tempMov");
    clips[rowCount].clipDuration = clips[rowCount].movieObject.duration();
    println(temp_clipNumber,  " " , temp_fileName);
    
    rowCount++;
    
  }
}
1 Like

hi, thanks for posting ( good formatted code ),
but if i understand correctly,
the whole question is NOT

  • about reading a table from csv file ( id , filename )
  • storing it to array of class

it is about loading a movie and get its duration?

    tempMov = new Movie(this, temp_fileName);
    println(tempMov.duration(), "tempMov");
    clips[rowCount].clipDuration = clips[rowCount].movieObject.duration();

i think there is a misunderstanding in that 3 lines,
-a- you load a movie from file to tempMov
-b- print its duration
? is that info at that line correctly shown?
-c- you want store the clip duration,
but you store something you not have loaded!

i think

    clips[rowCount].clipDuration = tempMov.duration();

might work better.
( but untested )