Android uses audiorecord to pause recording function instance code

Aside: I found that I haven't written a blog for a long time. The graduation project and the company doesn't have an Android project for the time being. I can only learn the knowledge on the web by myself. Up to now, it took more than a month to build a task management system in the company according to the company's existing template. I feel that it is a relatively shallow knowledge and there is nothing to write. Think of the speech recognition project done before, although there is nothing below now, but who knows ~ ~ ~ in the future?

To get back to business, the project leader looks like this:

Design idea:

Since the built-in audiorecord does not have a pauserecord() method, I call starting recording -- > (pause / resume recording)... -- > stopping recording a recording. Clicking a pause will generate a file (. PCM). Install all file names (. PCM) generated by a recording with a list. After clicking stop, I will traverse the list to obtain all file paths for splicing.

Considering that speech recognition may be carried out in the future, the flexibility and expansibility of the program are handled accordingly. You can monitor the recorded audio stream and the end of the recording through setlistener().

Thread pool is used to manage threads to reduce system overhead.

Description of class:

The following is the key code: 1. Audiorecorder class:

2:PcmToWav

3. Waveheader class:

Next is the renderings... Personal app interface must be beautiful and very beautiful, otherwise who will use your things! so~~

Well, please leave aside the UI to see the function ~ as expected, a PCM file will be generated every time you click pause. When you click stop, all recordings will be integrated into a playable. Wav file

Next, the project source code: click download

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>