If the previous test was successful, you can proceed to create the interface that allows you to take the picture. The method buildPlayer class PhotoCanvas usually initializes the object Player, but using "capture" as the protocol for the method createPlayer().
Code:
.. / /
public void buildPlayer ()
{
try
{
Manager.createPlayer player = ("capture: / / video");
player.realize ();
vc = (VideoControl) (player.getControl (VideoControl "));
if (vc == null)
{
/ / The videocontrol can not be created.
throw new MediaException ("Video control not supported");
}
else
{
vc.initDisplayMode (VideoControl.USE_DIRECT_VIDEO, this);
vcWidth vc.getDisplayWidth = int ();
vcHeight vc.getDisplayHeight = int ();
int x = (canvasWidth - vcWidth) / 2;
int y = (canvasHeight - vcHeight) / 2;
vc.setDisplayLocation (x, y);
}
}
....//
From the main midlet object is created PhotoCanvas and then start the player by calling startPlayer() , which uses a Boolean variable to see if the player is not already active (this is useful for restarting the player after it has captured image).
Code:
public void startPlayer ()
{
if (! playerActive)
{
try
{
if (imageCaptured! = null)
{
imageCaptured = null;
if (back! = null)
{
removeCommand (back);
}
}
if (player! = null)
{
player.start ();
}
if (vc! = null)
{
vc.setVisible (true);
}
playerActive = true;
}
catch (MediaException s)
{
e.printStackTrace ();
}
}
}
WTK does not exist in a capture device such as in camera phones, so when you start the application, the emulator will display a separate screen into rectangles that move from right to left.
Bookmarks