I an developing an android app. I want to accomplish below feature. I will use my phone's built-in mic to record and at the same time i want the recorded audio to be played through either phone's speakers or headphones. Is it feasible? If yes, please help me in this.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Here is a simple Recording and Playback application.
Uses Android AudioRecord and AudioTrack,
Code
The GUI has two Buttons START and STOP.
Enable the Button:
Mapping START and STOP Button for OnClickListener
Start the Thread:
Method for Initializing AudioRecord and AudioTrack:
The Values for
findAudioRecord
orfindAudioTrack
can change based on device.Please refer this question.
Code for Running the loop:
Please include the following in
AndroidManifest.xml
This above procedure is also possible by Writing/Reading from a file using the same APIs.
Why use
audioRecord
overmediaRecorder
- See here.The Code is tested (on Google Nexus 5) and working perfectly.
Note: Please add some error-checking code for
recorder.read
andtrack.write
, in case you fail. Same applies forfindAudioRecord
andfindAudioTrack
.As I read Developer document here , Android supports RTSP protocol (for real time streaming) and also HTTP/HTTPS live streaming draft protocol.
There is also an example here. You must have base knowledge about Streaming server, like Red5 or Wowza.
First create objects in onCreate method, MediaRecorder class object and the path to file where you want to save the recorded data.
These three function you can call it on any button, in order to play Rec, stop Rec and start Rec;