I put in a request for assistance on this issue a couple of weeks
back. I have finally had time to get some simple example code
working. What is happening is that I am recording an audio file using
Java sound, but playing it back with Quicktime. When I go to play the
audio with Quicktime the first time, it is perfect. Then I replace
the audio and try to play the new audio file with the same name. What
happens is that the first audio file is played. Quicktime appears to
be caching the audio file. In the example code I have here, it will
take the name of two audio files as input. It creates a copy of the
first audio and plays it. Then it replaces that audio with the second
audio and tries to play it. However, the first audio is played
instead. I appreciate any assistance.
File firstOriginalFile = new File(args[0]);
File tempPlayFile = new File(firstOriginalFile.getParentFile(),
"tempAudio.m4a");
copyFile(firstOriginalFile, tempPlayFile);
Movie movie = playMovie(tempPlayFile);
public static Movie playMovie(File file) throws QTException{
QTFile f = new QTFile(file);
OpenMovieFile omf = OpenMovieFile.asRead(f);
Movie movie = Movie.fromFile(omf);
TaskAllMovies.addMovieAndStart();
movie.start();
return movie;
}
/**
* Copies the target file or folder into the destination folder.
*
* @param target
* A file or folder to be copied.
* @param destination
* A folder where the target is to be copied into.
* @throws BackupReplicationException
*/
private static void copyFile(File target, File destination) throws
IOException {
// If the target file does not exist, return
if (target == null || !target.exists()) {
throw new IOException(target.getPath() + " does not exist.");
}
if (target.isFile()) {
// Create the subdirectories where the file will go into.
destination.getParentFile().mkdirs();
// Create the file where the data will be copied into.
if (!destination.exists()) {
destination.createNewFile();
}
InputStream inputStream = new BufferedInputStream(
new FileInputStream(target));
OutputStream outputStream = new BufferedOutputStream(
new FileOutputStream(destination));
byte[] copyData = new byte[256];
int length;
while ((length = inputStream.read(copyData)) != -1) {
inputStream.close();
outputStream.close();
}
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-java mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-java/email@hidden