Android multimedia audio and video recording MediaRecorder

Source: Internet
Author: User

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 ();

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.