Mediarecorder
Lifecycle
<1> Introduction
UseMediarecorder
Class for media sampling, including audio and video.Mediarecorder
Run as a state machine. You need to set different parameters, such as the source device and format. After setting, you can execute recording for any duration until the user stops.
<2>Mediarecorder
Common Methods
With the above method interface, it looks very easy to implement recording in Android. Below is a simple recordingCode:
Mediarecorder recorder = new mediarecorder (); recorder. setaudiosource (mediarecorder. audiosource. MIC); recorder. setoutputformat (mediarecorder. outputformat. three_gpp); recorder. setaudioencoder (mediarecorder. audioencoder. amr_nb); recorder. setoutputfile (path_name); recorder. prepare (); recorder. start (); // recording is now started... recorder. stop (); recorder. reset (); // You can reuse the object by going back to setaudiosource () Step recorder. release (); // now the object cannot be reused