无法使用 Samsung Galaxy S2 进行录音,但可以使用其他手机通过麦克风进行录音

发布于 2024-12-11 05:16:26 字数 626 浏览 1 评论 0原文

但是我的应用程序无法在 Samsung Galaxy S 2 中通过麦克风进行录音,它一直在其他手机中通过麦克风进行录音。

Recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
Recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
Recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

在我的代码中,我选择从 0 到 4 的源类型,选择编码器类型为 amr-nb、amr-wb、aac 或默认值,选择输出格式类型为 .3gp、.mp4 或 .amr,还选择音频通道如 1 或 2。 我尝试了所有可用的组合。至少其中一种组合适用于许多手机。但它们都不能在三星 Galaxy S 2 上工作。它记录了文件,记录的持续时间是真实的,但声音只是沉默!

在我对这个问题的网络研究中,我发现它可能源自麦克风类型。虽然在我的代码中我选择了默认的音频源类型,麦克风,语音下行,语音上行,语音呼叫,但它无法工作。然后我将音频源类型设置为硬,即 0, 1, 2, 3, 4 而不是 MediaRecorder.AudioSource.MIC 等。但它也无法工作......

However my app couldn't record in Samsung Galaxy S 2 from mic, it has been recording in other phones from mic.

Recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
Recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
Recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

In my code, I select the source type from 0 to 4, select the encoder type as amr-nb, amr-wb, aac or default, select the output format type as .3gp, .mp4 or .amr and also select audio channel as 1 or 2.
I try all of combinations which are up. At least one of the combinations work in many phones. But none of them could work in Samsung Galaxy S 2. It records the file and the duration of the record is true but the voice is only silence!

In my research in web with this problem, i find that it could be derived from the microphone type. Although in my code I select the audio source type as default, mic, voice downlink, voice uplink, voice call, it couldn't work. Then I set the audio source type as hard by that 0, 1, 2, 3, 4 instead of MediaRecorder.AudioSource.MIC etc. But it also couldn't work...

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

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

发布评论

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

评论(1

扎心 2024-12-18 05:16:26

我在 S2 上遇到过问题,应用程序会锁定麦克风并且不会释放它,特别是如果您正在进行快速开发周期,就像卸载应用程序(然后重新安装应用程序)一样锁定并释放麦克风。新版本)。有时它会在一段时间后解锁,但确保麦克风可用的可靠方法是在尝试失败后重新启动手机。

我已经能够使用 AudioRecord 对象中的以下设置来录制音频:

int buffer_size = 2 * AudioRecord.getMinBufferSize(16000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
recorder = new AudioRecord(
  MediaRecorder.AudioSource.MIC,               //audio source
  16000,                                       //16kHz sample rate
  AudioFormat.CHANNEL_IN_MONO,                 //channel
  AudioFormat.ENCODING_PCM_16BIT,              //encoding
  buffer_size );                               //buffer size

I've had issues on the S2 where an app will lock up the microphone and won't release it, especially if you are doing quick development cycles where you lock and release the mic just as you uninstall the app (and re-install a new version). Sometimes it unlocks after some time has passed, but the sure way to make sure the mic is available is to restart the phone after a failed attempt.

I've been able to record audio using the following settings in the AudioRecord object:

int buffer_size = 2 * AudioRecord.getMinBufferSize(16000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
recorder = new AudioRecord(
  MediaRecorder.AudioSource.MIC,               //audio source
  16000,                                       //16kHz sample rate
  AudioFormat.CHANNEL_IN_MONO,                 //channel
  AudioFormat.ENCODING_PCM_16BIT,              //encoding
  buffer_size );                               //buffer size
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文