如何通过使用Android的内置麦克风录制声音 [英] How to record sound by using inbuilt microphone in android

查看:985
本文介绍了如何通过使用Android的内置麦克风录制声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用移动自己的话筒......怎么办呢录制声音?

解决方案

它解释

  

从设备中音频采集有点   除音频更复杂/视频   播放,但仍然相当简单:

     
      
  1. 在使用创建android.media.MediaRecorder的新实例,新的
  2.   
  3. 设置使用MediaRecorder.setAudioSource音频源()。您   将可能需要使用   MediaRecorder.AudioSource.MIC
  4.   
  5. 在使用MediaRecorder.setOutputFormat()设置输出文件格式
  6.   
  7. 在使用MediaRecorder.setOutputFile()设置输出文件名
  8.   
  9. 在使用MediaRecorder.setAudioEn codeR()设置了音频连接codeR
  10.   
  11. 在MediaRecorder实例调用MediaRecorder。prepare()。
  12.   
  13. 要启动音频采集,调用MediaRecorder.start()。
  14.   
  15. 要停止音频采集,调用MediaRecorder.stop()。
  16.   
  17. 当你与MediaRecorder实例来完成,通话   MediaRecorder.release()就可以了。调用   MediaRecorder.release()总是   建议以释放资源   立即
  18.   

I need to record sound by using mobile's own microphone... How to do it?

解决方案

It's explained here

Audio capture from the device is a bit more complicated than audio/video playback, but still fairly simple:

  1. Create a new instance of android.media.MediaRecorder using new
  2. Set the audio source using MediaRecorder.setAudioSource(). You will probably want to use MediaRecorder.AudioSource.MIC
  3. Set output file format using MediaRecorder.setOutputFormat()
  4. Set output file name using MediaRecorder.setOutputFile()
  5. Set the audio encoder using MediaRecorder.setAudioEncoder()
  6. Call MediaRecorder.prepare() on the MediaRecorder instance.
  7. To start audio capture, call MediaRecorder.start().
  8. To stop audio capture, call MediaRecorder.stop().
  9. When you are done with the MediaRecorder instance, call MediaRecorder.release() on it. Calling MediaRecorder.release() is always recommended to free the resource immediately.

这篇关于如何通过使用Android的内置麦克风录制声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆