我的目标是使用Android相机捕捉视频并录制来自麦克风的声音。
我搜索了代码,但没有找到任何可行的示例或代码。
我尝试过的是
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);
我遇到了一个RuntimeException异常
java.lang.RuntimeException: setAudioSource失败。
出现在以下代码行:
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
尝试替换
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
但是这也不起作用。