super ("Basic Audio Controls");
// prompt for audio file
QTFile file = QTFile.standardGetFilePreview(null);
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);
// build balance, treble, bass controls in a panel
Panel controls = new Panel(new GridLayout (3,2));
controls.add (new JLabel ("Balance"));
balanceSlider = new JSlider (-1000, 1000, 0);
balanceSlider.addChangeListener (this);
controls.add (balanceSlider);
controls.add (new JLabel ("Treble"));
trebleSlider = new JSlider (-256, 256, 0);
trebleSlider.addChangeListener (this);
controls.add (trebleSlider);
controls.add (new JLabel ("Bass"));
bassSlider = new JSlider (-256, 256, 0);
bassSlider.addChangeListener (this);
controls.add (bassSlider);
add (controls, BorderLayout.SOUTH);