audio applications provide
some basic audio controls to allow the user to customize the sound
output to suit his environment. The
MovieController provides a volume control, but you
can do better than that: you can control balance, bass, and treble
with simple method calls.
class provides the methods
setSoundBassAndTreble( ), so it’s
just a matter of getting the handler object. The key is to remember
Movies have tracks.
Tracks have exactly one
Media has a
Iterate over the movie’s tracks to get each
track’s media and handler. To figure out whether a
given track is audio, you can use a simple
instanceof to see if the handler is an
setBalance( ) takes a
which ranges from
-1.0 (all the way to the left)
1.0 (all the way to the right), with
0 representing equal balance.
setSoundBassAndTreble( ) is interesting because
it’s officially undocumented. As it turns out, you
ints for bass and treble, where
0 is normal,
-256 is minimum
bass or treble, and
256 is maximum.
Well, the native version is undocumented. For once, the Javadocs have the useful info.
Example 7-3 provides a simple GUI to exercise these methods.
Run this example with ant run-ch07-basicaudiocontrolsplayer.
Example 7-3. Providing balance, bass, and treble controls
package com.oreilly.qtjnotebook.ch07; import quicktime.*; import quicktime.std.*; import quicktime.std.movies.*; ...