天天看點

我的Android進階之旅------>Android視訊錄制小例子 Audio Capture

============================首先看看官網上關于視訊捕捉的介紹================================

are managed for you automatically.

Unlike taking pictures with a device camera, capturing video requires a very particular call order. You must follow a specific order of execution to successfully prepare for and capture video with your application, as detailed below.

get an instance of the camera object.

begin displaying the live camera images.

Start Recording Video - The following steps must be completed in order to successfully record video:

documentation.

For versions of Android prior to 2.2, you must set the video output format and encoding parameters:

layout element for your application. Use the same object you specified for Connect Preview.

methods in this order, otherwise your application will encounter errors and the recording will fail.

Stop Recording Video - Call the following methods in order, to successfully complete a video recording:

fails.

creating a camera preview first and skip the first few steps of this process. However, since users typically prefer to see a preview before starting a recording, that process is not discussed here.

to starting your preview. This setting can help reduce the time it takes to start recording.

============================再看看官網上關于音頻捕捉的介紹================================

if supported by the device hardware.

This document shows you how to write an application that captures audio from a device microphone, save the audio and play it back.

Note: The Android Emulator does not have the ability to capture audio, but actual devices are likely to provide these capabilities.

Audio capture from the device is a bit more complicated than audio and video playback, but still fairly simple:

You will probably want to use<code>MediaRecorder.AudioSource.MIC</code>.

the MediaRecorder instance.

always recommended to free the resource immediately.

下面就看看該小例子的代碼吧。

檔案1.該應用的布局檔案,res/layout/main.xml

檔案2:布局檔案所用到的資源檔案,res/values/string.xml

 檔案3:該應用的主程式,RecoderActivity.java

檔案4:該應用的描述檔案 ,AndroidManifest.xml

=================================================================================================

  作者:歐陽鵬  歡迎轉載,與人分享是進步的源泉!

==================================================================================================

繼續閱讀