0

我正在开发一个 Android 自定义相机应用程序并尝试在其中实现录像机功能。我正在使用下面的代码

    private boolean prepareMediaRecorder()
    {
        myCamera = getCameraInstance();
        mediaRecorder = new MediaRecorder();
        myCamera.unlock();
        mediaRecorder.setCamera(myCamera);
        mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
        mediaRecorder.setPreviewDisplay(myCameraSurfaceView.getHolder().getSurface());
        try 
        {
            File newFile = File.createTempFile("videocapture", ".mp4", Environment.getExternalStorageDirectory());
            sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
            mediaRecorder.setOutputFile(newFile.getAbsolutePath());     
        } 
        catch (IOException e)
        {
            e.printStackTrace();
            finish();
        }
        try 
        {
            mediaRecorder.prepare();
        }
        catch (IllegalStateException e)
        {
            releaseMediaRecorder();
            return false;
        }
        catch (IOException e)
        {
            releaseMediaRecorder();
            return false;
        }
        return true;
    }

但是如果我使用相同的代码并在 Galaxy 选项卡上运行它,我会在这个代码位置强制关闭

             mediaRecorder.start();

错误日志如下所示。

http://textuploader.com/?p=6&id=ngcFk

当我改变时,代码在相同的情况下工作得很好

   mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));

   mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));

不明白为什么会这样。请帮忙!谢谢!

4

1 回答 1

0

您应该检查配置文件是否存在。我认为不支持选项卡。你可以试试hasprofile

于 2013-09-07T05:02:04.737 回答