Android multimedia audio and video recording MediaRecorder
Overview:
MediaRecorder status chart:
Initial: Initial state. When a MediaRecorder object is created using the new () method or the reset () method is called, The MediaRecZ prepare? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> vcmRlcrbUz/examples/templates + SW5pdGlhbGl6ZWSjutLRs/templates + templates/ release/bOxLz + release/Uyr61yLXIoaO/release + release/L/release + LP2tcS0yr3Q1/ZJZGxlIHN0YXRlIL/release + release/L/ j0tTNqLn9cmVzZXQoKbe9t6i9 + logs/K/aOst/HU8rvhs/bP1tLss6OhozwvcD4NCjxoMiBpZD0 = "code"> code:
Start recording audio:
MRecorder = new MediaRecorder (); // Sets the audio source to be used for recording and Sets the audio Resource mRecorder. setAudioSource (MediaRecorder. audioSource. MIC); // Sets the format of the output file produced during recording and Sets the output audio format mRecorder. setOutputFormat (MediaRecorder. outputFormat. THREE_GPP); // Sets the video encoder to be used for recording and Sets the audio encoding format mRecorder. setAudioEncoder (MediaRecorder. audioEncoder. AMR_NB); // Sets the path of the output file to be produced, and Sets the audio file output path mRecorder. setOutputFile (Environment. getExternalStorageDirectory () +/my_recorder.3gp); try {// Prepares the recorder to begin capturing and encoding data mRecorder. prepare (); // Begins capturing and encoding data to the file specified with setOutputFile () mRecorder. start ();} catch (IOException e) {e. printStackTrace ();}
Stop recording audio
// Stops recording mRecorder. stop (); // Restarts the MediaRecorder to its idle state mRecorder. reset (); // Releases resources associated with this MediaRecorder object to release the resource mRecorder. release ();