本文介绍了与MediaRecorder类问题设置音频源 - setAudioSource() - 不支持的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的Andr​​oid开发,我有一个问题/问题。

I'm new in Android development and I have the next question/problem.

我的MediaRecorder类玩弄记录从麦克风只是音频。我下面的官方网站指示的步骤: http://developer.android .COM /参考/安卓/媒体/ MediaRecorder.html

I'm playing around with the MediaRecorder class to record just audio from the microphone. I'm following the steps indicated in the official site: http://developer.android.com/reference/android/media/MediaRecorder.html

所以,我有一个初始化和配置MediaRecorder对象,以开始录制的方法。在这里,你有code:

So I have a method that initializes and configure the MediaRecorder object in order to start recording. Here you have the code:


        this.mr = new MediaRecorder();
        this.mr.setAudioSource(MediaRecorder.AudioSource.MIC);
        this.mr.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        this.mr.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        this.mr.setOutputFile(this.path + this.fileName);
        try {
            this.mr.prepare();
        } catch (IllegalStateException e) {
            Log.d("Syso", e.toString());
            e.printStackTrace();
        } catch (IOException e) {
            Log.d("Syso", e.toString());
            e.printStackTrace();
        }

当我在模拟器执行此code,感谢logcat的,我可以看到,该方法setAudioSource(MediaRecorder.AudioSource.MIC)给出了一个错误(与标签audio_ipunt)时,它被称为:

When I execute this code in the simulator, thanks to logcat, I can see that the method setAudioSource(MediaRecorder.AudioSource.MIC) gives the next error (with the tag audio_ipunt) when it is called:


ERROR/audio_input(34): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
ERROR/audio_input(34): VerifyAndSetParameter failed

然后当方法prepare()被调用时,我得到了再次另一个错误:

And then when the method prepare() is called, I get the another error again:


ERROR/PVOMXEncNode(34): PVMFOMXEncNode-Audio_AMRNB::DoPrepare(): Got Component OMX.PV.amrencnb handle 

如果我开始记录bycalling方法的start()...我得到很多消息说:

If I start to record bycalling the method start()... I get lots of messages saying:


AudioFlinger(34):RecordThread: buffer overflow

然后...后停止并释放,....我可以看到一个文件被创建,但它似乎并不认为这是很好recorderd。安韦,如果我尝试这在真实的设备,我可以没有任何问题记录,但我不能玩什么,我只是记录下来。

Then...after stop and release,.... I can see that a file has been created, but it doesn't seem that it been well recorderd. Anway, if i try this in a real device I can record with no problems, but I CAN'T play what I just recorded.

我客串,关键是在我之前提到的这些错误。我该如何解决这些问题?任何建议或帮助?

I gues that the key is in these errors that I've mentioned before. How can I fix them? Any suggestion or help??

在先进的感谢!

推荐答案

模拟器有很多与录音的问题。让我们说,这是行不通的。最好的办法就是试试你的code在真实设备!

The simulator has lots of issues with the audio recording. Lets say that it doesn't work. Your best bet is try your code in a real device!!!

这篇关于与MediaRecorder类问题设置音频源 - setAudioSource() - 不支持的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 16:48