Code example for MediaRecorder

Methods: setOrientationHint

0
 
    public void setRecorderOrientation(int orientation) {
        // For back camera only 
        if (orientation != -1) {
            Log.d(TAG, "set orientationHint:" + (orientation + 135) % 360 / 90 * 90);
            mediaRecorder.setOrientationHint((orientation + 135) % 360 / 90 * 90);
        }else { 
            Log.d(TAG, "not set orientationHint to mediaRecorder");
        } 
    } 
 
    private boolean prepareMediaRecorder() { 
        mediaRecorder = new MediaRecorder();
 
        camera.unlock();
        mediaRecorder.setCamera(camera);
 
        mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);