下面列出了怎么用android.hardware.Camera.ShutterCallback的API类实例代码及写法,或者点击链接到github查看源代码。
CaptureCallbacks(ShutterCallback shutter, PictureCallback raw, PictureCallback postView,
PictureCallback jpeg) {
mShutter = shutter;
mRaw = raw;
mPostView = postView;
mJpeg = jpeg;
}
public void requestTakePicture(
final ShutterCallback shutter,
final PictureCallback raw,
final PictureCallback postView,
final PictureCallback jpeg) {
final CaptureCallbacks callbacks = new CaptureCallbacks(shutter, raw, postView, jpeg);
obtainMessage(CameraActions.CAPTURE_PHOTO, callbacks).sendToTarget();
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public AutoFocusManager(final Context context, Camera camera,
final boolean canDisableSystemShutterSound) {
this.camera = camera;
this.executor = Executors.newSingleThreadScheduledExecutor();
this.focusAccelerationEventListener = new FocusAccelerationEventListener(
context, SensorManager.SENSOR_DELAY_GAME);
this.focusAmbientLightEventListener = new FocusAmbientLightEventListener(
context, SensorManager.SENSOR_DELAY_GAME);
String focusMode = this.camera.getParameters().getFocusMode();
this.must_call_auto_focus = Camera.Parameters.FOCUS_MODE_AUTO
.equals(focusMode)
|| Camera.Parameters.FOCUS_MODE_MACRO.equals(focusMode);
int[] soundRes = new int[0];
if (this.must_call_auto_focus) {
soundRes = Arrays.copyOf(soundRes, soundRes.length + 1);
soundRes[soundRes.length - 1] = R.raw.beep;
}
if (canDisableSystemShutterSound) {
soundRes = Arrays.copyOf(soundRes, soundRes.length + 1);
soundRes[soundRes.length - 1] = R.raw.shutter;
}
this.soundManager = new SoundManager(context, soundRes);
if (canDisableSystemShutterSound) {
this.shutterCallback = new ShutterCallback() {
@Override
public void onShutter() {
AutoFocusManager.this.soundManager.play(R.raw.shutter);
}
};
}
}