Hi Gorkem,
Thanks for the response, which seemed exactly what I hoped for
. I've used CaptureMidlet.java as the basis for my MIDlet, which is a LCDUI based camera demo (and works on my 5800). However when I run my eSWT MIDlet on the 5800 I get the following exception:
Code:
Error
java.lang.Error
SymbianOS error = -1 : General:
System error
It seems to exception on the line:
Code:
player = Manager.createPlayer("capture://video");
I haven't been able to test it on the 5th edition 0.9 emulator which doesn't seem to support camera emulation.
I've included my simple test case below, perhaps you can see the problem?
Code:
import java.io.IOException;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.control.GUIControl;
import javax.microedition.media.control.VideoControl;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import org.eclipse.ercp.swt.mobile.MobileShell;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
public class ESWT_Test extends MIDlet implements Runnable {
private Thread thread;
protected void startApp() throws MIDletStateChangeException {
if ( thread == null ) {
//The GUI needs to run in a separate thread than the MIDlet
thread = new Thread( this );
thread.start();
}
}
protected void pauseApp() {
}
protected void destroyApp( boolean unconditional ) throws MIDletStateChangeException {
}
public void run() {
MobileShell shell = null;
shell = new MobileShell(SWT.RESIZE | SWT.MIN |SWT.MAX | SWT.CLOSE);
shell.setSize(240,350);
shell.setText("Hello");
shell.setLayout(new FormLayout());
// creating player
Player player = null;
try {
player = Manager.createPlayer("capture://video");
} catch (IOException e) {
e.printStackTrace();
} catch (MediaException e) {
e.printStackTrace();
}
try {
player.realize();
player.prefetch();
} catch (MediaException e) {
e.printStackTrace();
}
// Grab the video control and set it to the current display.
VideoControl vcCam = (VideoControl) player.getControl("VideoControl");
// setting VideoControl to eSWT control
Control control = (Control) vcCam.initDisplayMode(
GUIControl.USE_GUI_PRIMITIVE, Control.class.getName());
// setting control to shell
control.setParent(shell);
try {
player.start();
} catch (MediaException e) {
e.printStackTrace();
}
shell.open();
Display display = shell.getDisplay();
while(!shell.isDisposed()) {
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Many thanks,
Jim