开发者

Android sound record problem

开发者 https://www.devze.com 2023-03-10 22:15 出处:网络
I\'m trying to record sound on android, using code basically just copied from the developer docs, here it is:

I'm trying to record sound on android, using code basically just copied from the developer docs, here it is:

    mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
    mFileName += "/audiorecordtest.3gp";
    mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    mRecorder.setOutputFile(mFileName);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

I get a runtime exception on开发者_如何学运维 the 4th line, I@m not sure why. Could you help?


Top tip: - Always check you've given your app the appropriate permissions! I forgot to let my app record sound.

0

精彩评论

暂无评论...
验证码 换一张
取 消