MediaRecorder: setCamera() - error camera is not a

2020-04-01 06:45发布

问题:

Anyone know how to using it for mediarecorder ? im using

recorder.setPreviewDisplay(holder.getSurface) where holder - it's camera ( i see chest rectangle on my screen of phone) When i runn my app - in logcat i see error (camera is not aviable) im try to using function setCamera - but it's not help me. Anyone know how to right use it ?

or maybe i can record video(only video, without audio) some other way?

ok SOLVED

this code for example

mediaRecorder = new MediaRecorder();
        camera.unlock();
        mediaRecorder.setCamera(camera);

回答1:

Have you forgot to set the permissions on your android manifest?

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

Now I read you have already answered it.

Don't forget to write is as an answer.

The solution would be:

mediaRecorder = new MediaRecorder();
camera.unlock();
mediaRecorder.setCamera(camera);