try {
QTSessionCheck.check();
QTFile movFile = new QTFile (new java.io.File("buildhref.mov"));
Movie movie =
Movie.createMovieFile(movFile,
StdQTConstants.kMoviePlayer,
StdQTConstants.createMovieFileDeleteCurFile |
StdQTConstants.createMovieFileDontCreateResFile);
System.out.println ("Created Movie");
// create an empty text track
int timeScale = 10; // time measured in 1/10ths of a sec
Track textTrack = movie.addTrack (TEXT_TRACK_WIDTH,
TEXT_TRACK_HEIGHT, 0);
System.out.println ("Added empty Track");
// create media for this track
Media textMedia = new TextMedia (textTrack,
timeScale);
TextMediaHandler handler =
(TextMediaHandler) textMedia.getHandler();
System.out.println ("Created Media");
textMedia.beginEdits();
for (int i=0; i<MESSAGES.length; i++) {
byte[] msgBytes = MESSAGES[i].getBytes();
QTPointer msgPoint = new QTPointer (msgBytes);
// add sample
handler.addTextSample (msgPoint, // text
0, // font number
14, // font size,
QDConstants.bold, // style,
QDColor.yellow, // fg color,
QDColor.black, // bg color,
QDConstants.teJustCenter,// justification
textBox, // box
0, // displayFlags
0, // scrollDelay
0, // hiliteStart
0, // hiliteEnd
QDColor.white, // rgbHiliteColor
25 // duration
);
} // for
// done editing
textMedia.endEdits();
// now insert this media into track
textTrack.insertMedia (0, // trackStart
0, // mediaTime
textMedia.getDuration(), // mediaDuration
1); // mediaRate
// add HREF track
Track hrefTrack = movie.addTrack (TEXT_TRACK_WIDTH,
TEXT_TRACK_HEIGHT, 0);
// create media for this track
Media hrefMedia = new TextMedia (hrefTrack,
timeScale);
handler = (TextMediaHandler) hrefMedia.getHandler();
System.out.println ("Created HREF Media");
hrefMedia.beginEdits();
for (int i=0; i<URLS.length; i++) {
byte[] msgBytes = URLS[i].getBytes();
QTPointer msgPoint = new QTPointer (msgBytes);
// add sample
handler.addTextSample (msgPoint, // text
0, // font number
14, // font size,
QDConstants.bold, // style,
QDColor.yellow, // fg color,
QDColor.black, // bg color,
QDConstants.teJustCenter,// justification
textBox, // box
0, // displayFlags
0, // scrollDelay
0, // hiliteStart
0, // hiliteEnd
QDColor.white, // rgbHiliteColor
25 // duration
);
} // for
// done editing
hrefMedia.endEdits();
// now insert this media into track
hrefTrack.insertMedia (0, // trackStart
0, // mediaTime
hrefMedia.getDuration(), // mediaDuration
1); // mediaRate
// disable href track because we don't want it visible
hrefTrack.setEnabled(false);
// change track name to HREFTrack
UserData userData = hrefTrack.getUserData();
String trackName = "HREFTrack";
QTPointer namePtr = new QTPointer(trackName.getBytes());
userData.setDataItem (namePtr,
QTUtils.toOSType("name"),
0);
// save up at this point
System.out.println ("Saving...");
OpenMovieFile omf = OpenMovieFile.asWrite (movFile);
movie.addResource (omf,
StdQTConstants.movieInDataForkResID,
movFile.getName());
System.out.println ("Done");
} catch (QTException qte) {
qte.printStackTrace();
}
System.exit(0);