AudioRecord 不适用于 Motorola Milestone
我仅在摩托罗拉 Milestone 上遇到此问题。代码:
// init recorder
recordInstance = new AudioRecord(MediaRecorder.AudioSource.MIC,
8000, AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT, 8000);
recordInstance.startRecording();
//more code here
recordInstance.stop();
我拥有的错误信息(暂时无法找到更多信息,因为我自己没有调试的里程碑):
Uncaught handler: thread main exiting due to uncaught exception
java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.
at android.media.AudioRecord.stop(AudioRecord.java:51 6)
显然我不是唯一遇到此问题的人。我发现了一些非常相似的线程(没有解决方案):
http://groups .google.com/group/android-developers/browse_thread/thread/6dd24aeb484b2e40 http://web.archive.org/web/20100824043744/http://androidcommunity.com:80/forums/f2/problem-using-audiorecord-in-motorola-milestone-30935/ http://community.developer.motorola.com/t5/Android-App-Development-for/Problem-using-AudioRecord-on-Milestone-device/mp/3889 http://www.fring.com/forums/showthread.php?t= 16194 http://groups.google.com/group/android-开发人员/browse_thread/thread/63be273ba59c635e/1c4a010fd470d328
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这应该有效:
只需坚持标准采样率 http://en.wikipedia.org/wiki/采样率#音频。我想知道为什么 Milestone 不支持 8bit 编码录制。这也给了我一个错误 - “无效的音频格式”。
This should work:
Just stick to the standard sample rates http://en.wikipedia.org/wiki/Sampling_rate#Audio. I wonder why Milestone does not support recording with 8bit encoding. This gives me an error too - "Invalid audio format".
首先,正如它所说,尝试在停止处放置一个 try catch 块,正如调试消息所说,记录正在进入 IllegalState。
也许如果你能捕获异常,你就能找出问题所在。
Firstly as it says try putting a try catch block over the stop, as the debugs message is saying, the recording is getting into an IllegalState.
Probably if u can catch the exception, you can find out what the problem is.
问题不是参数,问题是摩托罗拉对 Android 的修补的一个错误,如果模式是 IN_CALL,AudioRecord 将无法正确创建自己,如果它的 MODE_NORMAL 应该没问题。
这是因为摩托罗拉代码中的某些内容在 IN_CALL 模式下占用了输入。
The issue is not parameters, the issue is a bug with Motorola's tinkering of Android, the AudioRecord will not create itself properly if the mode is IN_CALL, if its MODE_NORMAL it should be fine.
This is because something in Motorolas code hogs the input when its IN_CALL mode.
理论上,hcpl 的代码应该可以工作,因为语音采样为 8kHz,但某些 Android 设备不接受它。
来自 Android 开发者网站的疯狂回答如下:
Theoretically, the hcpl's code should work because the speech sampling is 8kHz but some android devices doesn't accept it.
Completing the mad answer, from the Android Developers website: