有人可以提出解决方案吗?
流音频在MediaPlayer
类上播放。
为了录制,我以这种方式使用了MediaRecorder
类,
private void startRecording() {
isPlaying = true;
//we use the MediaRecorder class to record
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
/**In the lines below, we create a directory in the phone storage
* and the audios are being stored in the Audios folder **/
File root = android.os.Environment.getExternalStorageDirectory();
File file = new File(root.getAbsolutePath() + "/IRadio/Audios");
if (!file.exists()) {
file.mkdirs();
}
fileName = root.getAbsolutePath() + "/IRadio/Audios/" +
String.valueOf(System.currentTimeMillis() + ".mp3");
Log.d("filename",fileName);
mRecorder.setOutputFile(fileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
mRecorder.start();
} catch (IOException e) {
e.printStackTrace();
}
我已经读过关于字节对字节的音频here。但是无法理解如何用它替换我的代码。尽管我听说它不适用于MediaPlayer
类。任何建议或改进都表示赞赏。