本文整理了Java中android.hardware.Camera.unlock()
方法的一些代码示例,展示了Camera.unlock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Camera.unlock()
方法的具体详情如下:
包路径:android.hardware.Camera
类名称:Camera
方法名:unlock
暂无
代码示例来源:origin: guardianproject/haven
private boolean prepare(Camera camera) {
mCamera = camera;
mMediaRecorder = new MediaRecorder();
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setPreviewDisplay(mHolder.getSurface());
// mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
// mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
mMediaRecorder.setMaxDuration(mSeconds);
mMediaRecorder.setOutputFile(mOutputFile);
try {
mMediaRecorder.prepare();
} catch(IllegalStateException e) {
Log.d("ERROR", "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d("ERROR", "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testUnlock() throws Exception {
assertThat(shadowCamera.isLocked()).isTrue();
camera.unlock();
assertThat(shadowCamera.isLocked()).isFalse();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testReconnect() throws Exception {
camera.unlock();
assertThat(shadowCamera.isLocked()).isFalse();
camera.reconnect();
assertThat(shadowCamera.isLocked()).isTrue();
}
代码示例来源:origin: stackoverflow.com
mCamera.unlock();
代码示例来源:origin: stackoverflow.com
camera.unlock();
代码示例来源:origin: florent37/CameraFragment
try {
camera.lock();
camera.unlock();
videoRecorder.setCamera(camera);
代码示例来源:origin: stackoverflow.com
Camera camera = getCamera();
camera.stopPreview();
camera.lock();
camera.release();
camera = Camera.open();
camera.unlock();
代码示例来源:origin: stackoverflow.com
MediaRecorder mMediaRecorder = new MediaRecorder();
Camera mCamera = Camere.open();
Camera.Parameters parameters = mCamera.getParameters();
parameters.set("camera-id", 2);
parameters.setPreviewSize(640, 480); // or (800,480)
mCamera.setParameters(parameters);
mCamera.unlock(); // unlock, to give other process to access it otherwise it can't be used later
mMediaRecorder.setCamera(mCamera);
// continue with mMediaRecorder standard routines here
代码示例来源:origin: guoxiaoxing/phoenix
try {
camera.lock();
camera.unlock();
mMediaRecorder.setCamera(camera);
代码示例来源:origin: stackoverflow.com
myCamera.unlock();
代码示例来源:origin: hypeapps/Endoscope
protected void unlockCamera() {
if (!mUnlocked) {
Log.d(TAG,"Unlocking camera");
try {
mCamera.unlock();
} catch (Exception e) {
Log.e(TAG,e.getMessage());
}
mUnlocked = true;
}
}
代码示例来源:origin: Affectiva/android-sdk-samples
synchronized public void unlock() {
checkTaken();
camera.unlock();
}
代码示例来源:origin: stackoverflow.com
private void knowIfCameraIsAvailable() {
int camNumber = Camera.getNumberOfCameras();
System.out.println("Number of Camera = " + camNumber);
for (int i = 0; i < camNumber; i++) {
try {
Log.e("Camera ID", "ID == " + i);
Camera cam = Camera.open(i);
System.out.println("Camera object = " + cam);
Camera.Parameters camParameter = cam.getParameters();
System.out.println("camParameter.getMaxZoom() = "
+ camParameter.getMaxZoom());
cam.unlock();
cam.release();
} catch (NullPointerException e) {
Log.i("NullPointer", "Object NULL");
e.printStackTrace();
} catch (IllegalStateException e) {
Log.i("IllegalState", "Illegal State");
e.printStackTrace();
} catch (Exception e) {
Log.i("Exception", "Other Exception");
e.printStackTrace();
}
}
}
代码示例来源:origin: SingleShu/VideoRecord
/**
* 初始化摄像头
*
* @throws IOException
* @author zwj
* @date 2016-06-21
*/
private void initCamera() {
if (mCamera != null) {
freeCameraResource();
}
try {
mCamera = Camera.open();
if (mCamera == null)
return;
initParameters();
mCamera.setDisplayOrientation(90);//竖屏显示
mCamera.setPreviewDisplay(mSurfaceHolder);
mCamera.startPreview();
mCamera.unlock();
} catch (Exception e) {
e.printStackTrace();
freeCameraResource();
}
}
代码示例来源:origin: Gentleman-jun/VideoRecordDemo
/**
* 开始录制视频
*/
public boolean startRecord() {
initCamera();
//录制视频前必须先解锁Camera
mCamera.unlock();
configMediaRecorder();
try {
//开始录制
mediaRecorder.prepare();
mediaRecorder.start();
} catch (IOException e) {
return false;
}
return true;
}
代码示例来源:origin: stackoverflow.com
camera.unlock();
MediaRecorder recorder = new MediaRecorder();
recorder.setCamera(camera);
代码示例来源:origin: zhantong/AndroidCamera-TouchToFocusMeteringZoom
private boolean prepareVideoRecorder() {
mCamera = getCameraInstance();
mMediaRecorder = new MediaRecorder();
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String prefVideoSize = prefs.getString("video_size", "");
String[] split = prefVideoSize.split("x");
mMediaRecorder.setVideoSize(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
mMediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
mMediaRecorder.setPreviewDisplay(mHolder.getSurface());
int rotation = getDisplayOrientation();
mMediaRecorder.setOrientationHint(rotation);
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
}
代码示例来源:origin: huangfangyi/YiChat
private boolean startRecorderInternal() throws Exception {
shutdownCamera();
if (!initCamera())
return false;
switchCamera.setVisibility(View.GONE);
mediaRecorder = new MediaRecorder();
camera.unlock();
mediaRecorder.setCamera(camera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
setCamcorderProfile();
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mediaRecorder.setMaxDuration(1000 * VIDEO_TIMES);
mediaRecorder.setOutputFile(filename);
setVideoOrientation();
mediaRecorder.prepare();
mediaRecorder.start();
return true;
}
代码示例来源:origin: nglauber/dominando_android2
private boolean prepararGravacao() {
abrirCamera();
mCamera.unlock();
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mMediaRecorder.setOutputFile(mCaminhoArquivo.toString());
mMediaRecorder.setMaxDuration(60000); // 1 minuto
mMediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() {
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
concluirGravacao();
}
}
});
mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
try {
mMediaRecorder.prepare();
} catch (IOException e) {
e.printStackTrace();
liberarMediaRecorder();
return false;
}
return true;
}
private void concluirGravacao() {
代码示例来源:origin: zx391324751/weChatDemo
private void initRecorder() {
recorder = new MediaRecorder();
camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
if (camera != null) {
camera.setDisplayOrientation(90);//摄像图旋转90度
camera.unlock();
recorder.setCamera(camera);
}
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOrientationHint(90); //旋转90度
//480的清晰度,相当于高清视频与标清视频之间水准,10秒大概5mb左右
CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
recorder.setProfile(cpHigh);
recorder.setOutputFile(VIDEO_PATH); //文件名先随便写吧,毕竟只是demo
recorder.setMaxDuration(10000); // 10 seconds
recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
}
内容来源于网络,如有侵权,请联系作者删除!