Android使用MediaRecorder實現錄音功能

來源:互聯網
上載者:User

轉:http://www.ataaw.com/?p=419

 

手機的一個主要功能是多媒體功能,我們可以使用手機來播放各種音頻跟視頻,在Android的SDK中同樣提供了各種多媒體開發介面,供我們方便的開發出各類音視頻軟體,下面則是Android中提供的錄音介面的基本使用。

 

這裡我們列出幾個重要的使用方法,也是最常用的錄音介面。

1、MediaRecorder recorder = new MediaRecorder();  //初始化Recorder

2、recorder.setAudioSource(MediaRecorder.AudioSource.MIC);  //設定麥克風

3、 recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);//設定輸出格式

4、recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);  //設定音頻編碼Encoder

5、recorder.setOutputFile(“/sdcard/ataaw/ataaw.3gp”);  //設定音頻檔案儲存路徑

6、recorder.prepare();  //prepare

7、recorder.start();  //開始錄製

以上就是Android為我們提供的錄音開發介面基本使用方法,比較簡單方便的得以實現。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.