use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class AdvancedMultimediaManager method setFocus.
public void setFocus(Controllable player) {
FocusControl focusControl = (FocusControl) getControl(player, "javax.microedition.amms.control.camera.FocusControl");
if (focusControl != null) {
try {
if (focusControl.isMacroSupported() && !focusControl.getMacro()) {
focusControl.setMacro(true);
}
if (focusControl.isAutoFocusSupported()) {
focusControl.setFocus(FocusControl.AUTO);
try {
// let it focus...
Thread.sleep(FOCUS_TIME_MS);
} catch (InterruptedException ie) {
// continue
}
focusControl.setFocus(FocusControl.AUTO_LOCK);
}
} catch (MediaException me) {
// continue
}
}
}
use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class AdvancedMultimediaManager method setFocus.
public void setFocus(Controllable player) {
FocusControl focusControl = (FocusControl) getControl(player, "javax.microedition.amms.control.camera.FocusControl");
if (focusControl != null) {
try {
if (focusControl.isMacroSupported() && !focusControl.getMacro()) {
focusControl.setMacro(true);
}
if (focusControl.isAutoFocusSupported()) {
focusControl.setFocus(FocusControl.AUTO);
try {
// let it focus...
Thread.sleep(FOCUS_TIME_MS);
} catch (InterruptedException ie) {
// continue
}
focusControl.setFocus(FocusControl.AUTO_LOCK);
}
} catch (MediaException me) {
// continue
}
}
}
use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class AdvancedMultimediaManager method setExposure.
public void setExposure(Controllable player) {
ExposureControl exposureControl = (ExposureControl) getControl(player, "javax.microedition.amms.control.camera.ExposureControl");
if (exposureControl != null) {
int[] supportedISOs = exposureControl.getSupportedISOs();
if (supportedISOs != null && supportedISOs.length > 0) {
int maxISO = Integer.MIN_VALUE;
for (int i = 0; i < supportedISOs.length; i++) {
if (supportedISOs[i] > maxISO) {
maxISO = supportedISOs[i];
}
}
try {
exposureControl.setISO(maxISO);
} catch (MediaException me) {
// continue
}
}
String[] supportedMeterings = exposureControl.getSupportedLightMeterings();
if (supportedMeterings != null) {
for (int i = 0; i < supportedMeterings.length; i++) {
if (DESIRED_METERING.equals(supportedMeterings[i])) {
exposureControl.setLightMetering(DESIRED_METERING);
break;
}
}
}
}
}
use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class MMAPIPlayer method createPlayer.
/**
* @inheritDoc
*/
public static MMAPIPlayer createPlayer(String uri, Runnable onCompletion) throws IOException {
try {
Player p = Manager.createPlayer((String) uri);
p.realize();
MMAPIPlayer m = new MMAPIPlayer(p);
m.bindPlayerCleanupOnComplete(p, null, onCompletion);
return m;
} catch (MediaException ex) {
ex.printStackTrace();
throw new IOException(ex.toString());
}
}
use of javax.microedition.media.MediaException in project CodenameOne by codenameone.
the class CodeScannerImpl method startScan.
public void startScan() {
try {
System.gc();
player = Manager.createPlayer("capture://video");
player.realize();
multimediaManager.setZoom(player);
multimediaManager.setExposure(player);
multimediaManager.setFlash(player);
player.start();
videoControl = (VideoControl) player.getControl("VideoControl");
viewFinder = (Field) videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
if (videoControl != null) {
viewFinderScreen = new ViewFinderScreen();
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication().pushScreen(viewFinderScreen);
viewFinder.setFocus();
}
});
videoControl.setVisible(true);
videoControl.setDisplayFullScreen(true);
task = new BarcodeScanTask();
// create timer every 3 seconds, get a screenshot
timer = new Timer();
// once every 3 seconds
timer.schedule(task, 0, 3000);
} else {
throw new MediaException("Video Control is not initialized");
}
} catch (Exception e) {
callback.scanError(-1, e.getMessage());
}
}
Aggregations