I'm having trouble initializing the player. It throws a MediaException with Symbian OS error -5, "the operation requested is not supported".
It works just fine in WTK 2.2.
Here is the code:
Code:
class CameraForm extends Form implements CommandListener {
private final MyMIDlet midlet;
private final Command exitCommand;
private Command captureCommand = null;
private Player player;
private VideoControl videoControl;
private boolean active=false;
private StringItem messageItem;
public CameraForm(MyMIDlet midlet){
super("Camera");
this.midlet=midlet;
messageItem = new StringItem("Message","start");
append(messageItem);
exitCommand=new Command("Exit",Command.EXIT,1);
addCommand(exitCommand);
setCommandListener(this);
//initialize camera
try {
player = Manager.createPlayer("capture://video");
player.realize();
//Grab the videoControl and set it to the current display
videoControl=(VideoControl)(player.getControl("VideoControl"));
if(videoControl != null){
append((Item)(videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE,null)));
captureCommand = new Command("Capture",Command.SCREEN,1);
addCommand(captureCommand);
messageItem.setText("OK");
} else{
messageItem.setText("No video control");
}
} catch(IOException ioe){
messageItem.setText("IOException:"+ioe.getMessage());
}catch(MediaException me){
messageItem.setText("MediaException cameraForm(): "+me.getMessage());
}catch(SecurityException se){
messageItem.setText("Securityexception:"+se.getMessage());
}
}
}