我在我的应用程序中使用MediaRecorder来录制语音数据。我希望实现暂停,因为它在SDK中不可用
我正在录制语音到临时文件。当用户点击暂停按钮时,我会将录制的语音附加到文件中,该文件最初在应用启动时打开
事情并没有像预期的那样发生。任何人都可以帮助我吗?
任何帮助表示赞赏
感谢
我已尝试使用此代码。
recorder.stop();
recorder.reset();
System.out.println("recording stopped");
File inFile = new File(recorderOutFile);
try {
FileInputStream fin = new FileInputStream(inFile);
recordFileStream = new FileOutputStream(recordingFile, true);
int size = fin.available();
byte buffer[] = new byte[size];
System.out.println("Buffer size:" + size + "\td:"
+ new String(buffer));
fin.read(buffer);
recordFileStream.write(buffer);
recordFileStream.flush();
recordFileStream.close();
fin.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
recorder.reset();
System.out.println("recording stopped");
File inFile = new File(recorderOutFile);
try {
FileInputStream fin = new FileInputStream(inFile);
recordFileStream = new FileOutputStream(recordingFile, true);
int size = fin.available();
byte buffer[] = new byte[size];
System.out.println("Buffer size:" + size + "\td:"
+ new String(buffer));
fin.read(buffer);
recordFileStream.write(buffer);
recordFileStream.flush();
recordFileStream.close();
fin.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}