开发者

Recording sound in android

开发者 https://www.devze.com 2023-02-23 12:24 出处:网络
I\'d like to know how to record sound for a specific amount of time, without saving it to a file - holding in a byte stream for example. Also, if possible, make it look like an AMR file. I\'ve tried

I'd like to know how to record sound for a specific amount of time, without saving it to a file - holding in a byte stream for example. Also, if possible, make it look like an AMR file. I've tried to search google, and also wrote some code myself, but had no success. If you can link me开发者_JS百科 to a page that explains how to do so, or give an example, it would be very nice of you :)

Thanks.


MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setOutputFile(fileName);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

recorder.prepare();
recorder.start();

I'm not sure if you can skip the setOutputFile step and keep the recording in memory (probably not).

0

精彩评论

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

关注公众号