Android records sound files (audio) and plays them

This example shares the specific code of Android recording audio files for your reference. The specific contents are as follows

1. There is no detailed processing for clicking the same sound file for many times in this demo. There will be occasional crashes. You should pay attention to it when using it.

2. Press and hold the recording button. During recording, only the vertical direction is processed, and the horizontal direction is not written;

3. There is no operation to delete a sound file, but the function is implemented during the test. If necessary, it is described in detail in todo in mainactivity - > onItemClick;

4. This is just a demo. If you want to use it in a project, write the demo first, no problem, and then import the project. After writing the demo, when running on the real machine, you'd better choose "allow" if you get recording permission. If you refuse, you may crash.

Remember to turn on the permission of the mobile phone to run recording

First come the renderings:

Directory structure:

1. Add permissions:

2. Create a new mediarecorderutils and copy the following source code:

3. Create mychrome and copy the following code

4. Create tool class

package com.chen.voicedemo;

5、MainActivity

6、activity_ Main layout

7、voice_ Popupwindow layout code: when recording, the popupwindow in the following picture will appear

8. There is also an animation layout. When playing sound, there is an animation effect

Appendix: description of picture resources used: if you don't have such a picture, you can use other pictures to replace it. If it works, it will be successful

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
分享
二维码
< <上一篇
下一篇>>