我正在尝试使用mediaRecorder制作一个简单的屏幕录像机
我有一个按钮来启动和停止
MediaRecorder Mrecord = new MediaRecorder ();
VideoView videoView = (VideoView)findViewById (R.id.video);
Button button =(Button)findViewById (R.id.bytton);
String videoUri = "";
button.setOnClickListener (new View.onClickListener() {
@Override
public void onClick (View v){
if (button.getText () == "start"){
StartRecording ();
button.setText ("stop");
}
else{
StopRecording ();
button.setText ("start);
}
public void Startrecording(){
try {
Mrecord.setAudioSource (MediaRecorder.AudioSource.MIC);
Mrecord.setVideoSource (MediaRecorder.VideoSource.SURFACE);
Mrecord.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
Mrecord.setVideoSize (720,1280);
Mrecord.setVideoEncoder (MediaRecorder.VideoEncoder.H264);
Mrecord.setAudioEncoder (MediaRecorder.AudioEncoder.AMR_NB);
Mrecord.setOutputFile (videoUri);
Mrecord.setprepare ();
Mrecord.start ();
}
catch (IOException e){
e.printStackTrack ();
}
}
public void StopRecording (){
try {
Mrecord.stop ();}
catch (Exception e){
e.printStackTrace ();}
Mrecord.reset ();
Mrecord.release ();
Mrecord = null;
videoView.setVideoURI(Uri.parse (videoUri));
videoView.start ();
}
但是当我想播放视频时,我会收到错误消息
无法播放此视频
请任何人都可以帮助我解决这个问题。