How to limit audio recording time using Intent?

前端 未结 4 1220
青春惊慌失措
青春惊慌失措 2021-02-19 00:47

How can I limit recording when using intents?

I tried this code:

 Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
 intent.putExtra(\"android         


        
相关标签:
4条回答
  • 2021-02-19 01:44
    private void recordVideo() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);
    
    // set video quality
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 30);
    
    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set Video file
    startActivityForResult(intent, CAMERA_CAPTURE_VIDEO_REQUEST_CODE);
    }
    

    fileuri is your filepath. Try this.

    0 讨论(0)
  • 2021-02-19 01:44
        intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 60);
    
    0 讨论(0)
  • 2021-02-19 01:46

    you should be try with MediaRecorder mRecorder = new MediaRecorder(); and mRecorder.setMaxDuration(5000) // 5 seconds;

    0 讨论(0)
  • 2021-02-19 01:53

    I Have a similar problem and I fixed my problem using below code snippet:

    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
    cameraIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 5);
    startActivityForResult(this, cameraIntent,CAMERA_PIC_REQUEST);
    

    where CAMERA_PIC_REQUEST is my int type as:

    private static final int CAMERA_PIC_REQUEST = 1337;
    
    0 讨论(0)
提交回复
热议问题