视频播放器:
两个相关类:VideoView, MediaController
相关代码:
VideoView video;
MediaController ctlr;
File clip = new File("/sdcard/test.mp4");
if(clip.exists())
{
video = (VideoView) findViewById(r.id.video);
video.setVideoPath(clip.getAbsolutePath());
ctlr= new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
}
音视频的录制:
相关类:MediaRecorder,主要函数:start()开始录制, pause()暂停录制, stop()停止录制,prepare()准备录制,reset()重新开始,release()释放资源.
相关代码:
MediaRecorder mr;
mr = new MediaRecorder();
mr.setAudioSource(MediaRecorder.AudioSource.MIC);
mr.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mr.setAudioEncoder(MediaRecorder.AudioEncoder,AMR_NB);
String path = "/sdcard/test1.mp3";
mr.setOutputFile(path);
mr.prepare();
mr.start();
mr.stop();
mr.release();