Intent to take video in android

做~自己de王妃 提交于 2019-12-04 04:57:32

There is no reliable way to use intent to show the front camera all the time at least not on all devices. Only way to reliably do it is to create a SurfaceView and capture the video yourself.

AB DC

See if this works :

try {
    if (Camera.getNumberOfCameras() == 2) {
        if (frontCamera) {
            frontCamera = false;
            prCamera.stopPreview();
            prMediaRecorder.release();
            prMediaRecorder = null;
            prCamera.release();
            prCamera = null;
        } else {

            frontCamera = true;
            prCamera.stopPreview();
            prMediaRecorder.release();
            prMediaRecorder = null;
            prCamera.release();
            prCamera = null;
        }
        Intent intent = new Intent(VideoCapture_New.this,
                VideoCapture_New.class);
        startActivity(intent);
    } else {
        Toast.makeText(VideoCapture_New.this,
                "Your device doesn't contain Front Camera.",
                Toast.LENGTH_SHORT).show();
    }
} catch (Exception e) {
    e.printStackTrace();
    Toast.makeText(VideoCapture_New.this,
            "Your device is not compatible for Front Camera.",
            Toast.LENGTH_SHORT).show();

}

source : Front camera in android

Else you could use Android keyEvents to trigger the button press of camera switch if video starts to record on back camera. KeyEvents need to timed perfectly otherwise they end triggering something else! Check : KeyEvent.

Also if you are making use of

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

This signature for CamcorderProfile.get() defaults to a profile for the back-facing camera. So instead of using this, use :

public static CamcorderProfile get (int cameraId, int quality)

mediaRecorder.setVideoFrameRate(15);

use any value, 1 - 15 for frame rate. check this for additional details.

Hope this helps.

Create your custom video taking application that assure to only use the Front camera

i think this is the only way to do this .

Hope that Helps .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!