MediaRecorder error

I'm new here. I am trying to create a video capture app using an Android emulator without much success. As far as I know and go through all the samples and code on the internet (this site and others), I should still skip the step.

I tried using this sample at the end of this thread made by JonPro: http://www.anddev.org/viewtopic.php?p=24723#24723

and I tried to make my own, but the media recorder always failed in the prep phase with the most unhelpful message saying "failed to prepare". I have no idea what I am missing. I seem to have the correct permissions and the SDCard is mounted according to the emulator. Should I be using Android SDK version other than 2.1?

Even though the code on this forum claims to work, I realized that this line was missing: recorder.setCamera (camera);

But so far there is no joy as the logs show that: 'Failed to get camera parameters (0x16b70) when the prepare () method was called, but that still doesn't make sense as the preview is fine but no entry! Any help or suggestions would be appreciated.

Edit: Can anyone confirm that this might work for the SDK and emulator? or am I wasting my time trying to get this to work in this version. Can I get the source code for the provisioning function since this is OpenSource?

+2


source to share


2 answers


The fix for this issue is mCameraDevice.unlock () needs to be installed before provisioning. It is important that this is set after mCameraDevice.setPreviewDisplay (mHolder);

Example:



/*--------------------------------------surfaceCreated---------------------------------------------*/
/**
 * Surface Created sets that the surface is created.
 */
 public void surfaceCreated(SurfaceHolder arg0) {
     // TODO Auto-generated method stu1595
        try {
            Log.d(LOG_TAG, "setPreviewDisplay enter");
            mCameraDevice.setPreviewDisplay(mHolder);
            Log.d(LOG_TAG, "setPreviewDisplay exit");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        mCameraDevice.unlock();
        Log.d("*************", "***********unlock()****");
     isSurfaceCreated = true;


 }

      

BR PN

+5


source


recorder.setVideoSize(176, 144);
recorder.setVideoFrameRate(20);
recorder.setAudioChannels(1);
recorder.setPreviewDisplay( mHolder.getSurface());

      



it helped me. Look in logcat while debugging

0


source







All Articles