javax.microedition.media.Controllable Java Examples

The following examples show how to use javax.microedition.media.Controllable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void setZoom(Controllable player) {
  ZoomControl zoomControl = (ZoomControl) getControl(player, "javax.microedition.amms.control.camera.ZoomControl");
  if (zoomControl != null) {
    // We zoom in if possible to encourage the viewer to take a snapshot from a greater distance.
    // This is a crude way of dealing with the fact that many phone cameras will not focus at a
    // very close range.
    int maxZoom = zoomControl.getMaxOpticalZoom();
    if (maxZoom > NO_ZOOM) {
      zoomControl.setOpticalZoom(maxZoom > MAX_ZOOM ? MAX_ZOOM : maxZoom);
    } else {
      int maxDigitalZoom = zoomControl.getMaxDigitalZoom();
      if (maxDigitalZoom > NO_ZOOM) {
        zoomControl.setDigitalZoom(maxDigitalZoom > MAX_ZOOM ? MAX_ZOOM : maxDigitalZoom);
      }
    }
  }
}
 
Example #2
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void setFlash(Controllable player) {
  FlashControl flashControl =
      (FlashControl) getControl(player, "javax.microedition.amms.control.camera.FlashControl");
  if (flashControl != null) {
    int[] supportedFlash = flashControl.getSupportedModes();
    if (supportedFlash != null && supportedFlash.length > 0) {
      for (int i = 0; i < supportedFlash.length; i++) {
        if (supportedFlash[i] == DESIRED_FLASH) {
          try {
            flashControl.setMode(DESIRED_FLASH);
          } catch (IllegalArgumentException iae) {
            // continue
          }
          break;
        }
      }
    }
  }
}
 
Example #3
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
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 {
          Thread.sleep(FOCUS_TIME_MS); // let it focus...
        } catch (InterruptedException ie) {
          // continue
        }
        focusControl.setFocus(FocusControl.AUTO_LOCK);
      }
    } catch (MediaException me) {
      // continue
    }
  }
}
 
Example #4
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void setFlash(Controllable player) {
    FlashControl flashControl =
            (FlashControl) getControl(player, "javax.microedition.amms.control.camera.FlashControl");
    if (flashControl != null) {
        int[] supportedFlash = flashControl.getSupportedModes();
        if (supportedFlash != null && supportedFlash.length > 0) {
            for (int i = 0; i < supportedFlash.length; i++) {
                if (supportedFlash[i] == DESIRED_FLASH) {
                    try {
                        flashControl.setMode(DESIRED_FLASH);
                    } catch (IllegalArgumentException iae) {
                        // continue
                    }
                    break;
                }
            }
        }
    }
}
 
Example #5
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
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 {
                        Thread.sleep(FOCUS_TIME_MS); // let it focus...
                    } catch (InterruptedException ie) {
                        // continue
                    }
                    focusControl.setFocus(FocusControl.AUTO_LOCK);
                }
            } catch (MediaException me) {
                // continue
            }
        }
    }
 
Example #6
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void setZoom(Controllable player) {

        ZoomControl zoomControl = (ZoomControl) getControl(player, "javax.microedition.amms.control.camera.ZoomControl");
        if (zoomControl != null) {
            // We zoom in if possible to encourage the viewer to take a snapshot from a greater distance.
            // This is a crude way of dealing with the fact that many phone cameras will not focus at a
            // very close range.
            int maxZoom = zoomControl.getMaxOpticalZoom();
            if (maxZoom > NO_ZOOM) {
                zoomControl.setOpticalZoom(maxZoom > MAX_ZOOM ? MAX_ZOOM : maxZoom);
            } else {
                int maxDigitalZoom = zoomControl.getMaxDigitalZoom();
                if (maxDigitalZoom > NO_ZOOM) {
                    zoomControl.setDigitalZoom(maxDigitalZoom > MAX_ZOOM ? MAX_ZOOM : maxDigitalZoom);
                }
            }
        }
    }
 
Example #7
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
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;
        }
      }
    }

  }
}
 
Example #8
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
private static Control getControl(Controllable player, String fullName) {
  Control control = player.getControl(fullName);
  if (control == null) {
    String shortName = fullName.substring(fullName.lastIndexOf('.') + 1);
    control = player.getControl(shortName);
  }
  return control;
}
 
Example #9
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
private static Control getControl(Controllable player, String fullName) {
    Control control = player.getControl(fullName);
    if (control == null) {
        String shortName = fullName.substring(fullName.lastIndexOf('.') + 1);
        control = player.getControl(shortName);
    }
    return control;
}
 
Example #10
Source File: AdvancedMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
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;
                    }
                }
            }

        }
    }
 
Example #11
Source File: Spectator.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
Spectator( Controllable impl ) {
    _impl = impl;
}
 
Example #12
Source File: MultimediaManager.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void setFlash(Controllable player) {
}
 
Example #13
Source File: MultimediaManager.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void setExposure(Controllable player) {
}
 
Example #14
Source File: MultimediaManager.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void setZoom(Controllable player) { 
}
 
Example #15
Source File: MultimediaManager.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void setFocus(Controllable player) {  
}
 
Example #16
Source File: DefaultMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void setFlash(Controllable player) {
}
 
Example #17
Source File: DefaultMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void setExposure(Controllable player) {
}
 
Example #18
Source File: DefaultMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void setZoom(Controllable player) {
}
 
Example #19
Source File: DefaultMultimediaManager.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void setFocus(Controllable player) {
}
 
Example #20
Source File: MultimediaManager.java    From CodenameOne with GNU General Public License v2.0 votes vote down vote up
void setFlash(Controllable player); 
Example #21
Source File: MultimediaManager.java    From CodenameOne with GNU General Public License v2.0 votes vote down vote up
void setExposure(Controllable player); 
Example #22
Source File: MultimediaManager.java    From CodenameOne with GNU General Public License v2.0 votes vote down vote up
void setZoom(Controllable player); 
Example #23
Source File: MultimediaManager.java    From CodenameOne with GNU General Public License v2.0 votes vote down vote up
void setFocus(Controllable player);