Camera onPreviewFrame not called

前端 未结 4 1616
刺人心
刺人心 2020-12-09 08:36

when using the Camera.PreviewCallback implementation the onPreviewFrame is called without problem after initializing camera and starting preview (Camera.startPrevew()). The

4条回答
  •  我在风中等你
    2020-12-09 09:12

    I had a similar problem; see

    setOneShotPreviewCallback not hitting onPreviewFrame() in callback

    What I discovered was that after calling Camera#unlock() to prepare the MediaRecorder, it was necessary to call Camera#reconnect() before setting the preview callback. This is because Camera.unlock() detaches the camera from the process to let the MediaRecorder connect to it.

    http://developer.android.com/reference/android/hardware/Camera.html#unlock()

    In my investigations I also discovered that if you set any preview callbacks using other methods than the one shot method, you have to reset all of these after calling Camera#reconnect() as well. So, briefly:

    mCamera.unlock();
    //set up MediaRecorder
    mCamera.reconnect();
    mCamera.setPreviewCallback(mCallback);
    //or whatever callback method you want to use
    //and even if you've set this callback already
    

    I hope that helps!

提交回复
热议问题