android.media
public
class
android.media.MediaRecorder
Used to record audio and video.
See the Android Media APIs
page for help using using MediaRecorder.
Nested Classes
Summary
Public Constructors
Public Methods
Protected Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Public Constructors
public
MediaRecorder()
Default constructor.
Public Methods
public
int
getMaxAmplitude()
Returns the maximum absolute amplitude that was sampled since the last
call to this method. Call this only after
the audio source has been set.
Returns
- the maximum absolute amplitude measured since the last call, or
0 when called for the first time
public
void
prepare()
Prepares the recorder to begin capturing and encoding data. This method
must be called after setting up the desired audio and video sources,
encoders, file format, etc., and before start().
public
void
release()
Releases resources associated with this MediaRecorder object.
It is good practice to call this method when you're done
using the MediaRecorder.
public
void
reset()
Restarts the MediaRecorder to its uninitialized state. After calling
this method, you will have to initialize it again as if it had just been
constructed.
public
void
setAudioEncoder(int audio_encoder)
Sets the audio encoder to be used for recording. If this method is not
called, the output file will not contain an audio track. Call this after
setOutputFormat() and before prepare().
Parameters
audio_encoder
| the audio encoder to use. |
public
void
setAudioSource(int audio_source)
Sets the audio source to be used for recording. If this method is not
called, the output file will not contain an audio track. The source needs
to be specified before setting recording-parameters or encoders. Call
this only before setOutputFormat().
Parameters
audio_source
| the audio source to use |
public
void
setOutputFile(String path)
Sets the path of the output file to be produced. Call this after
setOutputFormat() and before prepare().
Parameters
path
| The pathname to use() |
public
void
setOutputFormat(int output_format)
Sets the format of the output file produced during recording. Call this
before prepare().
Parameters
output_format
| the output format to use. The output format
needs to be specified before setting recording-parameters or encoders. |
public
void
setPreviewDisplay(Surface sv)
Sets a Surface to show a preview of recorded media (video).
Parameters
sv
| the Surface to use for the preview
|
public
void
setVideoEncoder(int video_encoder)
Sets the video encoder to be used for recording. If this method is not
called, the output file will not contain an video track. Call this after
setOutputFormat() and before prepare().
Parameters
video_encoder
| the video encoder to use. |
public
void
setVideoFrameRate(int rate)
Sets the frame rate of the video to be captured. Must be called
after setVideoSource(). Call this after setOutFormat() but before prepare().
Parameters
rate
| the number of frames per second of video to capture |
public
void
setVideoSize(int width, int height)
Sets the width and height of the video to be captured. Must be called
after setVideoSource(). Call this after setOutFormat() but before prepare().
Parameters
width
| the width of the video to be captured |
height
| the height of the video to be captured |
public
void
setVideoSource(int video_source)
Sets the video source to be used for recording. If this method is not
called, the output file will not contain an video track. The source needs
to be specified before setting recording-parameters or encoders. Call
this only before setOutputFormat().
Parameters
video_source
| the video source to use |
public
void
start()
Begins capturing and encoding data to the file specified with
setOutputFile(). Call this after prepare().
public
void
stop()
Stops recording. Call this after start().
Protected Methods
protected
void
finalize()
Called by the virtual machine when there are no longer any (non-weak)
references to the receiver. Subclasses can use this facility to guarantee
that any associated resources are cleaned up before the receiver is
garbage collected. Uncaught exceptions which are thrown during the
running of the method cause it to terminate immediately, but are
otherwise ignored.
Note: The virtual machine assumes that the implementation in class Object
is empty.