Java Reference
In-Depth Information
implementations (supporting the LCDUI), USE GUI PRIMITIVE results in
an instance of a javax.microedition.lcdui.Item being returned,
and it can be added to a Form in the same way as any other Item subclass.
USE DIRECT VIDEO mode can only be used with implementations that
support the LCDUI (such as Symbian OS) and a second argument of
type javax.microedition.lcdui.Canvas (or a subclass) must be
supplied. This is the approach adopted in the example code above.
Methods of VideoControl can be used to manipulate the size and the
location of the video with respect to the canvas where it is displayed.
Since we are using direct video as the display mode, it is necessary
to call setVisible(true) in order for the video to be displayed.
Finally, we start the rendering of the video with the startPlayer()
The other methods of the VideoPlayer class are the same as their
namesakes in the AudioPlayer class of the Audio Player MIDlet.
The VideoCanvas class, where the video is shown, is very simple,
as the MMAPI implementation takes care of rendering the video file
correctly on the canvas:
public class VideoCanvas extends Canvas {
// code omitted for brevity
// Paints background color
public void paint(Graphics g) {
g.setColor(128, 128, 128);
g.fillRect(0, 0, getWidth(), getHeight());
The important point to note is that the paint() method plays no part
in rendering the video. This is performed directly by the VideoControl .
The full source code and JAR and JAD files for the Video Player MIDlet
can be downloaded from this topic's website.
2.9.6 Capturing Images
VideoControl is also used to capture images from a camera. In this
case, rather than specifying a file (and MIME type) as the data source, we
specify capture://video . Other than that, the setting up of the video
player and control proceeds pretty much as in the Video Player MIDlet
in Section 2.9.5.
The following code, which performs the necessary initialization of a
video player and a control, is reproduced from the VideoPlayer class
in the Video Player MIDlet example:
Search WWH ::

Custom Search