Android多媒体框架初步分析
2010-05-27 03:42:00 来源:WEB开发网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 start()
Begins capturing and encoding data to the file specified with setOutputFile().
void stop()
Stops recording.
简单的例子:
Example:
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
整体的结构如下图所示:
l MediaPlayer JNI
代码位置 /frameworks/base/media/jni
l MediaPlayer (Native)
代码位置 /frameworks/base/media/libmedia
l MediaPlayerService (Server)
代码位置 /frameworks/base/media/libmediaplayerservice
l MediaPlayerService Host Process
代码位置 /frameworks/base/media/mediaserver/main_mediaserver.cpp
l PVPlayer
代码位置 /external/opencore/android/
实际调用过程如下图所示:
更多精彩
赞助商链接