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);
soundChannel = new SGSoundChannel (grabber);
System.out.println ("Got audio, video channels");
videoChannel.setBounds (grabBounds);
// get settings
// yikes! these often crash java 1.4.2 on mac os x!
// see book for workaround (call these from non-AWT thread and block AWT on it)
// soundChannel.settingsDialog();
// videoChannel.settingsDialog();
// prepare and start previewing
videoChannel.setUsage (StdQTConstants.seqGrabRecord);
soundChannel.setUsage (StdQTConstants.seqGrabPreview |
StdQTConstants.seqGrabRecord);
soundChannel.setVolume (0.0f);
grabber.prepare(false, true);
grabber.startPreview();
// create output file
grabFile = new QTFile (new java.io.File ("audiovideograb.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();