记录在Android中给出异议异议、Android

2023-09-05 05:17:36 作者:一隅江山

当我尝试使用以下code来记录通过模拟器音频

When I am trying to record an audio through the emulator using following code

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

然后我得到以下情况例外在logcat中:

Then I am getting following exceptions in logcat:

12-16 19:07:31.680: INFO/jdwp(223): Ignoring second debugger -- accepting and dropping
12-16 19:07:31.700: ERROR/AudioHardware(34): Error opening input channel
12-16 19:07:31.720: WARN/AudioHardwareInterface(34): getInputBufferSize bad sampling rate: 11025
12-16 19:07:31.730: ERROR/AudioRecord(294): Recording parameters are not supported: sampleRate 11025, channelCount 1, format 1
12-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-8
12-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)

您可以弄清楚什么是错的这个code?

Can you figure out what's wrong in this code?

推荐答案

此外,请确保您有此权限在AndroidManifest.xml中设置: <使用-权限的Andr​​oid:名称=android.permission.RECORD_AUDIO/>

Also, make sure that you have this permission set in your AndroidManifest.xml: <uses-permission android:name="android.permission.RECORD_AUDIO" />

 
精彩推荐
图片推荐