Methods Summary |
---|
private native void | _prepare()
|
private native void | _setOutputFile(java.io.FileDescriptor fd, long offset, long length)
|
protected void | finalize() native_finalize();
|
public native int | getMaxAmplitude()Returns the maximum absolute amplitude that was sampled since the last
call to this method. Call this only after the setAudioSource().
|
private final native void | native_finalize()
|
private native void | native_reset()
|
private final native void | native_setup(java.lang.Object mediarecorder_this)
|
private static void | postEventFromNative(java.lang.Object mediarecorder_ref, int what, int arg1, int arg2, java.lang.Object obj)Called from native code when an interesting event happens. This method
just uses the EventHandler system to post the event back to the main app thread.
We use a weak reference to the original MediaRecorder object so that the native
code is safe from the object disappearing from underneath it. (This is
the cookie passed to native_setup().)
MediaRecorder mr = (MediaRecorder)((WeakReference)mediarecorder_ref).get();
if (mr == null) {
return;
}
if (mr.mEventHandler != null) {
Message m = mr.mEventHandler.obtainMessage(what, arg1, arg2, obj);
mr.mEventHandler.sendMessage(m);
}
|
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., but before start().
if (mPath != null) {
FileOutputStream fos = new FileOutputStream(mPath);
try {
_setOutputFile(fos.getFD(), 0, 0);
} finally {
fos.close();
}
} else if (mFd != null) {
_setOutputFile(mFd, 0, 0);
} else {
throw new IOException("No valid output file");
}
_prepare();
|
public native 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 idle state. After calling
this method, you will have to configure it again as if it had just been
constructed.
native_reset();
// make sure none of the listeners get called anymore
mEventHandler.removeCallbacksAndMessages(null);
|
public native 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() but before prepare().
|
public native 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().
|
public native void | setCamera(android.hardware.Camera c)Sets a Camera to use for recording. Use this function to switch
quickly between preview and capture mode without a teardown of
the camera object. Must call before prepare().
|
public native void | setMaxDuration(int max_duration_ms)Sets the maximum duration (in ms) of the recording session.
Call this after setOutFormat() but before prepare().
After recording reaches the specified duration, a notification
will be sent to the {@link android.media.MediaRecorder.OnInfoListener}
with a "what" code of {@link #MEDIA_RECORDER_INFO_MAX_DURATION_REACHED}
and recording will be stopped. Stopping happens asynchronously, there
is no guarantee that the recorder will have stopped by the time the
listener is notified.
|
public native void | setMaxFileSize(long max_filesize_bytes)Sets the maximum filesize (in bytes) of the recording session.
Call this after setOutFormat() but before prepare().
After recording reaches the specified filesize, a notification
will be sent to the {@link android.media.MediaRecorder.OnInfoListener}
with a "what" code of {@link #MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED}
and recording will be stopped. Stopping happens asynchronously, there
is no guarantee that the recorder will have stopped by the time the
listener is notified.
|
public void | setOnErrorListener(android.media.MediaRecorder$OnErrorListener l)Register a callback to be invoked when an error occurs while
recording.
mOnErrorListener = l;
|
public void | setOnInfoListener(android.media.MediaRecorder$OnInfoListener listener)Register a callback to be invoked when an informational event occurs while
recording.
mOnInfoListener = listener;
|
public void | setOutputFile(java.io.FileDescriptor fd)Pass in the file descriptor of the file to be written. Call this after
setOutputFormat() but before prepare().
mPath = null;
mFd = fd;
|
public void | setOutputFile(java.lang.String path)Sets the path of the output file to be produced. Call this after
setOutputFormat() but before prepare().
mFd = null;
mPath = path;
|
public native void | setOutputFormat(int output_format)Sets the format of the output file produced during recording. Call this
after setAudioSource()/setVideoSource() but before prepare().
It is recommended to always use 3GP format when using the H.263
video encoder and AMR audio encoder. Using an MPEG-4 container format
may confuse some desktop players.
|
public void | setPreviewDisplay(android.view.Surface sv)Sets a Surface to show a preview of recorded media (video). Calls this
before prepare() to make sure that the desirable preview display is
set.
mSurface = sv;
|
public native 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().
|
public native 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().
|
public native 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().
|
public native 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().
|
public native void | start()Begins capturing and encoding data to the file specified with
setOutputFile(). Call this after prepare().
|
public native void | stop()Stops recording. Call this after start(). Once recording is stopped,
you will have to configure it again as if it has just been constructed.
|