|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.media.MediaRecorder
public class MediaRecorder
Used to record audio and video. The recording control is based on a simple state machine (see below).
A common case of using MediaRecorder to record audio works as follows:
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
See the Android Media APIs page for additional help with using MediaRecorder.
| Nested Class Summary | |
|---|---|
class |
MediaRecorder.AudioEncoder
Defines the audio encoding. |
class |
MediaRecorder.AudioSource
Defines the audio source. |
class |
MediaRecorder.OutputFormat
Defines the output format. |
class |
MediaRecorder.VideoEncoder
Defines the video encoding. |
class |
MediaRecorder.VideoSource
Defines the video source. |
| Constructor Summary | |
|---|---|
MediaRecorder()
Default constructor. |
|
| Method Summary | |
|---|---|
protected void |
finalize()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. |
int |
getMaxAmplitude()
Returns the maximum absolute amplitude that was sampled since the last call to this method. |
void |
prepare()
Prepares the recorder to begin capturing and encoding data. |
void |
release()
Releases resources associated with this MediaRecorder object. |
void |
reset()
Restarts the MediaRecorder to its idle state. |
void |
setAudioEncoder(int audio_encoder)
Sets the audio encoder to be used for recording. |
void |
setAudioSource(int audio_source)
Sets the audio source to be used for recording. |
void |
setOutputFile(String path)
Sets the path of the output file to be produced. |
void |
setOutputFormat(int output_format)
Sets the format of the output file produced during recording. |
void |
setPreviewDisplay(Surface sv)
Sets a Surface to show a preview of recorded media (video). |
void |
setVideoEncoder(int video_encoder)
Sets the video encoder to be used for recording. |
void |
setVideoFrameRate(int rate)
Sets the frame rate of the video to be captured. |
void |
setVideoSize(int width,
int height)
Sets the width and height of the video to be captured. |
void |
setVideoSource(int video_source)
Sets the video source to be used for recording. |
void |
start()
Begins capturing and encoding data to the file specified with setOutputFile(). |
void |
stop()
Stops recording. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MediaRecorder()
| Method Detail |
|---|
public void setPreviewDisplay(Surface sv)
sv - the Surface to use for the preview
public void setAudioSource(int audio_source)
throws IllegalStateException
audio_source - the audio source to use
IllegalStateException - if it is called after setOutputFormat()MediaRecorder.AudioSource
public void setVideoSource(int video_source)
throws IllegalStateException
video_source - the video source to use
IllegalStateException - if it is called after setOutputFormat()MediaRecorder.VideoSource
public void setOutputFormat(int output_format)
throws IllegalStateException
output_format - the output format to use. The output format
needs to be specified before setting recording-parameters or encoders.
IllegalStateException - if it is called after prepare() or before
setAudioSource()/setVideoSource().MediaRecorder.OutputFormat
public void setVideoSize(int width,
int height)
throws IllegalStateException
width - the width of the video to be capturedheight - the height of the video to be captured
IllegalStateException - if it is called after
prepare() or before setOutputFormat()
public void setVideoFrameRate(int rate)
throws IllegalStateException
rate - the number of frames per second of video to capture
IllegalStateException - if it is called after
prepare() or before setOutputFormat().
public void setAudioEncoder(int audio_encoder)
throws IllegalStateException
audio_encoder - the audio encoder to use.
IllegalStateException - if it is called before
setOutputFormat() or after prepare().MediaRecorder.AudioEncoder
public void setVideoEncoder(int video_encoder)
throws IllegalStateException
video_encoder - the video encoder to use.
IllegalStateException - if it is called before
setOutputFormat() or after prepare()MediaRecorder.VideoEncoder
public void setOutputFile(String path)
throws IllegalStateException
path - The pathname to use()
IllegalStateException - if it is called before
setOutputFormat() or after prepare()
public void prepare()
throws IllegalStateException
IllegalStateException - if it is called after
start() or before setOutputFormat().
public void start()
throws IllegalStateException
IllegalStateException - if it is called before
prepare().
public void stop()
throws IllegalStateException
IllegalStateException - if it is called before start()public void reset()
public int getMaxAmplitude()
throws IllegalStateException
IllegalStateException - if it is called before
the audio source has been set.public void release()
protected void finalize()
ObjectNote: The virtual machine assumes that the implementation in class Object is empty.
finalize in class Object
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||