媒体录制器在启动时崩溃

时间:2016-05-05 16:12:34

标签: android mediarecorder

我的媒体录像机有问题。它不能开始,来到活动线程。我找不到问题。所有权限设置。 谢谢你帮帮我:)

private void startCaptureVideo()
    {
        camera = getCameraInstance();
        //cameraPreview = new cameraPreview(this,camera);
        try {

            surfaceHolder =  selfImage.getHolder();
            camera.setPreviewDisplay(surfaceHolder);
            camera.startPreview();
       } catch (IOException e) {
            e.printStackTrace();
        }

        camera.lock();
        if(checkCameraHardware(this)) {
            mediaRecorder.setCamera(camera);
            mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
            mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
            File file = new File(this.getFilesDir(), "masterVideo"+System.currentTimeMillis());
            mediaRecorder.setOutputFile(file.getPath());
            mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
            mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
            mediaRecorder.setVideoSize(selfImage.getWidth(), selfImage.getHeight());
            try {
                mediaRecorder.prepare();
               // mediaRecorder.start();
            } catch (IOException e) {
                e.printStackTrace();
            }
            mediaRecorder.start();
        }
        else
            Toast.makeText(this,":( :( :(",Toast.LENGTH_SHORT);
    }

0 个答案:

没有答案