Programming Concepts
The Multimedia Java API is based around four main types of classes in the javax.microedition.media
package—the Manager
, the Player
, the PlayerListener
and various types of Control
.
Java ME programmers wishing to use JSR 135 would first make use of the static methods of the Manager
class. Although there are other methods such as playTone
, the main method used is createPlayer
. This takes either a URI or an InputStream
, and a MIME type. In most cases, URIs are used. Common URI protocols used include:
- file:
- resource: (which may extract a file from within the JAR of the MIDlet, but is implementation-dependent)
- http:
- rtsp:
- capture: (used for recording audio or video)
The MIME type is optional, and is inferred from the data passed in if not supplied.
The createPlayer
method returns an implementation of the Player
interface (even if you use a capture: protocol URI). This has core methods that are applicable to all players, such as starting and stopping the media, and requesting that it loop. You can also setPlayerListener
to an object implementing the PlayerListener
interface, which will receive various events related to the clip (starting, stopping, media finishing, etc.)
Player
classes also have a getControl
method that returns an implementation of a particular Control
. A Control
handles any optional APIs which are not applicable to all media types. Any given Player
may or may not be able to supply an implementation of any given Control
.
(Typically, the Control
returned is actually the Player
itself, but this is not guaranteed to be the case.)
The set of controls implemented by a Player
is not limited; however, some standard ones are defined in the javax.microedition.media.control
package by the JSR:
Control Interface | Description |
---|---|
FramePositioningControl | A control for video data that allows access to individual frames. |
GUIControl | A control for data that requires a display, such as video. |
MetaDataControl | Used to determine the metadata information stored within amedia stream, such as title, copyright, author, and so on. |
MIDIControl | A fully functional control that enables access to a device’s MIDI player. |
PitchControl | Used to control the pitch (frequency) of audio data. |
RateControl | Used to control the playback rate of a Player. |
RecordControl | Allows you to control the recording of data from a capture device, such as video from a camera or audio from a sound recorder. |
StopTimeControl | A control that allows you to set a preset time when you want the Player to stop playing. |
TempoControl | Similar to RateControl, this control allows you to change the tempo (speed) of playback for an audio Player, typically, a MIDI Player. |
ToneControl | A fully functional control that allows you to play monotonic tone sequences. |
VideoControl | Extends GUIControl and controls the display of video. |
VolumeControl | The simplest control that allows you to control the volume of audio in a Player . |
(Others may be defined in JSR 234 (Advanced Multimedia Supplements).
A subset of JSR 135 is defined in JSR 118 (MIDP 2.0).
Read more about this topic: Java Mobile Media API
Famous quotes containing the words programming and/or concepts:
“If there is a price to pay for the privilege of spending the early years of child rearing in the drivers seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.”
—Melinda M. Marshall (20th century)
“It is impossible to dissociate language from science or science from language, because every natural science always involves three things: the sequence of phenomena on which the science is based; the abstract concepts which call these phenomena to mind; and the words in which the concepts are expressed. To call forth a concept, a word is needed; to portray a phenomenon, a concept is needed. All three mirror one and the same reality.”
—Antoine Lavoisier (17431794)