super ("Audio Level Meter");
// prompt for audio file
QTFile file = QTFile.standardGetFilePreview(
QTFile.kStandardQTFileTypes);
OpenMovieFile omf = OpenMovieFile.asRead (file);
Movie movie = Movie.fromFile (omf);
MovieController controller = new MovieController (movie);
// get AudioMediaHandler for first audio track
for (int i=1; i<=movie.getTrackCount(); i++) {
Track t = movie.getTrack(i);
Media m = t.getMedia();
MediaHandler mh = m.getHandler();
if (mh instanceof AudioMediaHandler) {
audioMediaHandler = (AudioMediaHandler) mh;
break;
}
}
if (audioMediaHandler == null) {
System.out.println ("No audio track");
System.exit(-1);
}
// add controller to GUI
setLayout (new BorderLayout());
Component comp =
QTFactory.makeQTComponent(controller).asComponent();
add (comp, BorderLayout.NORTH);
// add level meter to GUI
meter = new LevelMeter();
add (meter, BorderLayout.SOUTH);
// set up repainting timer
Timer t = new Timer (50, new ActionListener() {
public void actionPerformed (ActionEvent ae) {
meter.repaint();
}
});
t.start();