import javax.microedition.amms.control.camera.ExposureControl;
import javax.microedition.amms.control.camera.FocusControl;
import javax.microedition.amms.control.camera.ZoomControl;
-import javax.microedition.media.Control;
import javax.microedition.media.Controllable;
import javax.microedition.media.MediaException;
/**
- * <p>See {@link DefaultMultimediaManager} documentation for details.</p>
- *
- * <p>This class should never be directly imported or reference in the code.</p>
+ * <p>Implementation suitable for JSR-234 phones which takes advantage of advanced camera
+ * capability.</p>
*
* @author Sean Owen (srowen@google.com)
*/
private static final String DESIRED_METERING = "center-weighted";
AdvancedMultimediaManager() {
- // Another try at fixing Issue 70. Seems like FocusControl et al. are sometimes not
- // loaded until first use in the setFocus() method. This is too late for our
- // mechanism to handle, since it is trying to detect this API is not available
- // at the time this class is instantiated. We can't move the player.getControl() calls
- // into here since we don't have a Controllable to call on, since we can't pass an
- // arg into the constructor, since we can't do that in J2ME when instantiating via
- // newInstance(). So we just try writing some dead code here to induce the VM to
- // definitely load the classes now:
- Control dummy = null;
- ExposureControl dummy1 = (ExposureControl) dummy;
- FocusControl dummy2 = (FocusControl) dummy;
- ZoomControl dummy3 = (ZoomControl) dummy;
}
public void setFocus(Controllable player) {
import javax.microedition.media.Controllable;
/**
- * <p>This class encapsulates optional multimedia-related operations that the device
- * may support, like setting focus and zoom. This implementation itself will do nothing.
- * It will attempt to dynamically instantiate {@link com.google.zxing.client.j2me.AdvancedMultimediaManager}
- * which has methods that call JSR-234 APIs to actually set focus, zoom, etc. If successful,
- * this class will delegate to that implementation. But if the phone does not support these
- * APIs, instantiation will simply fail and this implementation will do nothing.</p>
- *
- * <p>Credit to Paul Hackenberger for the nice workaround</p>
+ * <p>Dummy implemenation which does nothing. This is suitable for non-JSR-234 phones.</p>
*
* @author Sean Owen (srowen@google.com)
- * @author Paul Hackenberger
*/
-class DefaultMultimediaManager implements MultimediaManager {
-
- private MultimediaManager advancedMultimediaManager;
+final class DefaultMultimediaManager implements MultimediaManager {
DefaultMultimediaManager() {
- // Having issues with non-JSR-234 phones not accepting the build? then try commenting out from here:
- try {
- advancedMultimediaManager = (MultimediaManager)
- Class.forName("com.google.zxing.client.j2me.AdvancedMultimediaManager").newInstance();
- } catch (ClassNotFoundException cnfe) {
- // continue
- } catch (IllegalAccessException iae) {
- // continue
- } catch (InstantiationException ie) {
- // continue
- } catch (NoClassDefFoundError ncdfe) {
- // continue
- }
- // to here. Then add this line:
- // advancedMultimediaManager = null;
- // You may also need to delete the class AdvancedMultimediaManager in this package to be completely free
- // of JSR-234 references.
}
public void setFocus(Controllable player) {
- if (advancedMultimediaManager != null) {
- advancedMultimediaManager.setFocus(player);
- }
}
public void setZoom(Controllable player) {
- if (advancedMultimediaManager != null) {
- advancedMultimediaManager.setZoom(player);
- }
}
public void setExposure(Controllable player) {
- if (advancedMultimediaManager != null) {
- advancedMultimediaManager.setExposure(player);
- }
}
}
\ No newline at end of file