Java Reference
In-Depth Information
Controlling the Rendering Process
For all but the simplest of media players, you will want to have additional control over
media playback. While the
Player
interface itself lets you start and stop playback, you can
do a lot more by obtaining instances of specific
Control
subclasses that let you change the
Player
's behavior. To get an instance of a specific kind of control, you pass the name of
the desired class (with the package name, if it's not
javax.microedition.media.control
)to
the
Player
's
getControl
method, like this:
VolumeControl vc = (VolumeControl)player.getControl("VolumeControl");
Each
Control
subclass has different methods, reflecting the kind of control over the
media rendering process it offers. Table 16-3 describes some
Control
subinterfaces that
come in handy when writing multimedia applications. Of course, not every subinterface
is available for a
Player
instance rendering every media type; it would make little sense,
for example, to be able to obtain a
VideoControl
for an audio file, or a
TempoControl
for a
video file.
Table 16-3.
Implementors of Control You Can Use to Control Media Rendering
Interface
Purpose
Example Methods
FramePositioningControl
Seek to a specific video frame
seek
skip
mapFrameToTime
mapTimeToFrame
GUIControl
initDisplayMode
Provide an object to render the
media to the GUI
MetaDataControl
getKeys
getKeyValue
Obtain metadata in a media file
MIDIControl
Controlling an internal synthesizer
various
PitchControl
getMaxPitch
Shift pitch of synthesized or sampled
getMinPitch
getPitch
setPitch
audio without changing playback speed
RateControl
getMaxRate
getMinRate
getRate
setRate
Shift playback rate
RecordControl
commit
setRecordLocation
setRecordStream
startRecord
stopRecord
Record media from a player