本文整理了Java中android.media.MediaRecorder.setCamera()
方法的一些代码示例,展示了MediaRecorder.setCamera()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MediaRecorder.setCamera()
方法的具体详情如下:
包路径:android.media.MediaRecorder
类名称:MediaRecorder
方法名:setCamera
暂无
代码示例来源: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 testCamera() throws Exception {
assertThat(shadowMediaRecorder.getCamera()).isNull();
Camera c = Shadow.newInstanceOf(Camera.class);
mediaRecorder.setCamera(c);
assertThat(shadowMediaRecorder.getCamera()).isNotNull();
assertThat(shadowMediaRecorder.getCamera()).isSameAs(c);
}
代码示例来源:origin: stackoverflow.com
mCamera.unlock();
mrec.setCamera(mCamera);
代码示例来源:origin: stackoverflow.com
mediaRecorder.setCamera(camera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
代码示例来源:origin: florent37/CameraFragment
camera.lock();
camera.unlock();
videoRecorder.setCamera(camera);
代码示例来源: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
camera.lock();
camera.unlock();
mMediaRecorder.setCamera(camera);
代码示例来源:origin: stackoverflow.com
mediaRecorder.setCamera(myCamera);
代码示例来源:origin: stackoverflow.com
MediaRecorder recorder = new MediaRecorder();
recorder.setCamera(camera);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.prepare();
代码示例来源:origin: stackoverflow.com
recorder.setCamera(camera);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.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: werbhelius/MediaUtils
if (recorderType == MEDIA_VIDEO) {
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
代码示例来源:origin: stackoverflow.com
public void surfaceCreated(SurfaceHolder holder) {
mCamera.unlock();
mRecorder.setCamera(mCamera);
代码示例来源:origin: stackoverflow.com
Camera mCamera = getCameraInstance();
// adjust the camera the way you need
mCamera.setDisplayOrientation(90);
MediaRecorder recorder = new MediaRecorder();
recorder.setCamera(mCamera);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
recorder.setOutputFile(filePath);
// add any limits
recorder.setMaxDuration(50000); // 50 seconds
recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
代码示例来源:origin: stackoverflow.com
Socket socket = new Socket(serverAddr, serverPort);
socket.setTcpNoDelay(true);
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
Camera camera = Camera.open();
camera.unlock();
MediaRecorder recorder = new MediaRecorder();
recorder.setCamera(camera);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
recorder.setOutputFile(pfd.getFileDescriptor());
recorder.setPreviewDisplay(surfaceView.getHolder().getSurface());
recorder.setVideoFrameRate(15);
recorder.setVideoSize(480, 320);
recorder.prepare();
recorder.start();
代码示例来源: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
}
代码示例来源:origin: stackoverflow.com
public class VideoHolderCallback implements SurfaceHolder.Callback{
MediaRecorder recorder;
...
public void configureRecorder(){
if(camera == null) {
camera = Camera.open();
camera.unlock();
}
recorder.setCamera(camera);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
recorder.setOutputFile(filePath);
recorder.setPreviewDisplay(holder.getSurface());
recorder.prepare();
}
代码示例来源:origin: Car-eye-team/Car-eye-device
mrs[index] = new MediaRecorder();
mrs[index].reset();
mrs[index].setCamera(camera[index]);
mrs[index].setVideoSource(MediaRecorder.VideoSource.CAMERA);
String starttime;
内容来源于网络,如有侵权,请联系作者删除!