Android 录音机中的暂停
我在我的应用程序中使用 MediaRecorder 来录制语音数据。我想实现暂停,因为它在 SDK 中不可用。
我正在将语音录制到临时文件中。当用户单击暂停按钮时,我会将录制的语音附加到文件中,该文件最初在应用程序启动时打开。
事情并没有按预期发生。谁能帮我吗?
如有任何帮助,我们将不胜感激。
谢谢
编辑
我已经尝试过这段代码。
<代码> 录音机.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();
}
<代码>
I am using MediaRecorder in my app for recording voice data. I want to implement pause as it is not available in SDK.
I am recording voice to temporary file. When user clicks pause button, I will append that recorded voice to a file, which is opened initially when app launches.
The things are not happening as expected. Can anyone help me?
Any help is appreciated.
Thanks
Edit
I have tried out with this code.
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();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论