在Android中录制提供例外情况

在Android中录制提供例外情况,第1张

概述当我尝试使用以下代码通过模拟器录制音频时AudioRecordrecordInstance=newAudioRecord(MediaRecorder.AudioSource.MIC,this.getFrequency(),this.getChannelConfiguration(),this.getAudioEncoding(),bufferSize);然后我在logcat中得到以下异常:12

当我尝试使用以下代码通过模拟器录制音频时

  AudioRecord recordInstance = new AudioRecord(    MediaRecorder.AudioSource.MIC, this.getFrequency(), this      .getChannelConfiguration(), this.getAudioEnCoding(),    bufferSize);

然后我在logcat中得到以下异常:

12-16 19:07:31.680: INFO/jDWp(223): Ignoring second deBUGger -- accepting and dropPing12-16 19:07:31.700: ERROR/AudioHarDWare(34): Error opening input channel12-16 19:07:31.720: WARN/AudioHarDWareInterface(34): getinputBufferSize bad sampling rate: 1102512-16 19:07:31.730: ERROR/AudioRecord(294): Recording parameters are not supported: sampleRate 11025, channelCount 1, format 112-16 19:07:31.730: ERROR/AudioRecord-JNI(294): Error creating AudioRecord instance: initialization check Failed.12-16 19:07:31.730: ERROR/AudioRecord-Java(294): [ androID.media.AudioRecord ] Error code -20 when initializing native AudioRecord object.12-16 19:07:31.730: WARN/dalvikvm(294): threadID=7: thread exiting with uncaught exception (group=0x4001d800)12-16 19:07:31.770: ERROR/AndroIDRuntime(294): FATAL EXCEPTION: Thread-812-16 19:07:31.770: ERROR/AndroIDRuntime(294): java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.12-16 19:07:31.770: ERROR/AndroIDRuntime(294):     at androID.media.AudioRecord.startRecording(AudioRecord.java:495)12-16 19:07:31.770: ERROR/AndroIDRuntime(294):     at com.prospeak.Recorder.run(Recorder.java:84)12-16 19:07:31.770: ERROR/AndroIDRuntime(294):     at java.lang.Thread.run(Thread.java:1096)

你能弄清楚这段代码中有什么问题吗?

解决方法:

你的采样率是错误的,尝试8000Hz.这是一个模拟器限制.

总结

以上是内存溢出为你收集整理的在Android中录制提供例外情况全部内容,希望文章能够帮你解决在Android中录制提供例外情况所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1099069.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存