// first try a local file using the dataPath. usually this will
// work ok, but sometimes the dataPath is inside a jar file,
// which is less fun, so this will crap out.
File file = new File(parent.dataPath(filename));
if (file.exists()) {
movie = fromDataRef(new DataRef(new QTFile(file)));
//init(parent, movie, ifps);
//return;
}
} catch (Exception e) { } // ignored
// read from a folder local to the current working dir
// called "data". presumably this might be the data folder,
// though that should be caught above, if such a folder exists.
/*
if (movie == null) {
try {
File file = new File("data", filename);
if (file.exists()) {
movie = fromDataRef(new DataRef(new QTFile(file)));
init(parent, movie, ifps);
return;
}
} catch (QTException e2) { }
}
*/
// read from a file just hanging out in the local folder.
// this might happen when the video library is used with some
// other application, or the person enters a full path name
if (movie == null) {
try {
File file = new File(filename);
if (file.exists()) {
movie = fromDataRef(new DataRef(new QTFile(file)));
//init(parent, movie, ifps);
//return;
}
} catch (QTException e1) { }
}
} catch (SecurityException se) {
// online, whups. catch the security exception out here rather than
// doing it three times (or whatever) for each of the cases above.
}
// if the movie can't be read from a local file, it has to be read
// into a byte array and passed to qtjava. it's annoying that apple
// doesn't have something in the api to read a movie from a friggin
// InputStream, but oh well. it's their api.
if (movie == null) {
byte data[] = parent.loadBytes(filename);
//int dot = filename.lastIndexOf(".");
// grab the extension from the file, use mov if there is none
//String extension = (dot == -1) ? "mov" :
// filename.substring(dot + 1).toLowerCase();
try {
movie = fromDataRef(new DataRef(new QTHandle(data)));
} catch (QTException e) {
e.printStackTrace();
}
}