Search in sources :

Example 6 with MediaException

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
        }
    }
}
Also used : FocusControl(javax.microedition.amms.control.camera.FocusControl) MediaException(javax.microedition.media.MediaException)

Example 7 with MediaException

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
        }
    }
}
Also used : FocusControl(javax.microedition.amms.control.camera.FocusControl) MediaException(javax.microedition.media.MediaException)

Example 8 with MediaException

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;
                }
            }
        }
    }
}
Also used : MediaException(javax.microedition.media.MediaException) ExposureControl(javax.microedition.amms.control.camera.ExposureControl)

Example 9 with MediaException

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());
    }
}
Also used : Player(javax.microedition.media.Player) MediaException(javax.microedition.media.MediaException) IOException(java.io.IOException)

Example 10 with MediaException

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());
    }
}
Also used : Timer(java.util.Timer) MediaException(javax.microedition.media.MediaException) MediaException(javax.microedition.media.MediaException)

Aggregations

MediaException (javax.microedition.media.MediaException)10 IOException (java.io.IOException)4 Player (javax.microedition.media.Player)4 ExposureControl (javax.microedition.amms.control.camera.ExposureControl)2 FocusControl (javax.microedition.amms.control.camera.FocusControl)2 Timer (java.util.Timer)1 VideoControl (javax.microedition.media.control.VideoControl)1