Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to capture a video for particular time interval in Android

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.30k
    Comment on it

    If you are looking to capture a video for particular time interval using default camera, then follow the below code to achieve the same.


    Record video from camera for 60 seconds

    private void captureVideoFromCamera(){
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 60); 
        intent.putExtra("EXTRA_VIDEO_QUALITY", 0);
        startActivityForResult(intent, CAPTURE_VIDEO_REQUEST);
    }
    

    Here the maximum duration is 60 seconds and not 60 milliseconds.


    If you are calling this method from Fragment, then use:

    getActivity().startActivityForResult(intent, CAPTURE_VIDEO_REQUEST);

    But if you are calling this method from Activity then simply write the below code.

    startActivityForResult(intent, CAPTURE_VIDEO_REQUEST);

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: