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).
精彩评论