Vishal Khakhkhar
Vishal Khakhkhar

Reputation: 2116

Video + Audio Recorder Android

My Goal is to capture Video using Android Camera and Record Voice from Mic.

I googled code but couldn't get any working example or code.

what I've tried is


        recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);

        CamcorderProfile cpHigh = CamcorderProfile
                .get(CamcorderProfile.QUALITY_HIGH);
        recorder.setProfile(cpHigh);
        recorder.setOutputFile("/sdcard/videocapture_example.mp4");
        recorder.setMaxDuration(50000); // 50 seconds
        recorder.setMaxFileSize(5000000); // Approximately 5 megabytes

        recorder.setVideoSize(320, 240); 
        recorder.setVideoFrameRate(15); 

I'm getting a RuntimeException

java.lang.RuntimeException: setAudioSource failed.

on the following line

recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);

tried with replacing

recorder.setAudioSource(MediaRecorder.AudioSource.MIC);

but this doesn't work either.

Upvotes: 4

Views: 2481

Answers (2)

bezz
bezz

Reputation: 1688

Don't forget to set permissions in manifest.xml

<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.CAMERA" />

Upvotes: 4

Niels
Niels

Reputation: 49909

This is a bug within android. See http://code.google.com/p/android/issues/detail?id=4075

You can just try this:

recorder.setAudioSource(0); // Or 1, don't know which Enum is right.

Because there is a mismatch in Enums.

Upvotes: 1

Related Questions