grabber = new SequenceGrabber();
System.out.println ("got grabber");
// force an offscreen gworld
grabBounds = new QDRect (320, 240);
gw = new QDGraphics (grabBounds);
grabber.setGWorld (gw, null);
// get videoChannel and set its bounds
videoChannel = new SGVideoChannel (grabber);
System.out.println ("Got SGVideoChannel");
videoChannel.setBounds (grabBounds);
/*
// get settings
// yikes! this crashes java 1.4.2 on mac os x!
videoChannel.settingsDialog();
*/
// kludgey - should do a wait()/notify() block instead
final SGVideoChannel vc = videoChannel;
Thread t = new Thread() {
public void run() {
try {
vc.settingsDialog();
} catch (QTException qte) {
qte.printStackTrace();
}
}
};
t.start();
while (t.isAlive())
Thread.yield();
// prepare and start previewing
// note - second prepare arg should seemingly be false,
// but if it is, you get erroneous dskFulErr's
videoChannel.setUsage (StdQTConstants.seqGrabRecord);
grabber.prepare(false, true);
// TODO: do I still want this?
grabber.startPreview();
// create output file
grabFile = new QTFile (new java.io.File ("videograb.mov"));
grabber.setDataOutput(grabFile,
StdQTConstants.seqGrabToDisk
//seqGrabDontAddMovieResource);
);
grabber.startRecord();
grabbing = true;
// set up thread to idle
ActionListener timerCallback =
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (grabbing) {
try {
System.out.println ("idle");
grabber.idle();
grabber.update(null);
} catch (QTException qte) {
qte.printStackTrace();
}
}
}
};
Timer timer = new Timer (50, timerCallback);
timer.start();