Android - 录音机 FileNotFound

发布于 2024-08-25 08:48:50 字数 592 浏览 4 评论 0原文

我正在尝试录制音频

this.recorder = new android.media.MediaRecorder();
this.recorder.setAudioSource(android.media.MediaRecorder.AudioSource.MIC);      this.recorder.setOutputFormat(android.media.MediaRecorder.OutputFormat.DEFAULT);
this.recorder.setAudioEncoder(android.media.MediaRecorder.AudioEncoder.DEFAULT);
this.recorder.setOutputFile("pruebaAudioRecorder.mp4");
**this.recorder.prepare();**
this.recorder.start();

,但是当我调用准备方法时会抛出 FileNotFound 异常。

  • 我应该在准备方法之前创建文件吗?类似于 new File(...)
  • 如果是这样,文件路径应该是哪个?

非常感谢。

I'm trying to record audio

this.recorder = new android.media.MediaRecorder();
this.recorder.setAudioSource(android.media.MediaRecorder.AudioSource.MIC);      this.recorder.setOutputFormat(android.media.MediaRecorder.OutputFormat.DEFAULT);
this.recorder.setAudioEncoder(android.media.MediaRecorder.AudioEncoder.DEFAULT);
this.recorder.setOutputFile("pruebaAudioRecorder.mp4");
**this.recorder.prepare();**
this.recorder.start();

but when i call prepare method throws the FileNotFound exception.

  • Should I create the file before prepare method? something like new File(...)
  • If so, which should be the file path?

thx a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尴尬癌患者 2024-09-01 08:48:50

这是一个很好的解决方案,请记住添加 WRITE_EXTERNAL_STORAGE 权限

http://www .benmccann.com/blog/android-audio-recording-tutorial/

here is a great solution, remember to add the WRITE_EXTERNAL_STORAGE permission

http://www.benmccann.com/blog/android-audio-recording-tutorial/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文