修复预览闪退的问题
This commit is contained in:
parent
f0440075dd
commit
88b58944bd
@ -275,17 +275,7 @@ public class MediaRecorderActivity extends Activity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setStopUI() {
|
private void setPreviewUI(){
|
||||||
mCameraSwitch.setEnabled(true);
|
|
||||||
mRecordLed.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPreviewUI() throws IOException {
|
|
||||||
File file = new File(mMediaObject.getOutputTempTranscodingVideoPath());
|
|
||||||
if(!file.exists() || file.length() == 0){
|
|
||||||
Toast.makeText(this,"录制失败",3000).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mMediaRecorder.stopPreview();
|
mMediaRecorder.stopPreview();
|
||||||
mCameraSwitch.setVisibility(View.INVISIBLE);
|
mCameraSwitch.setVisibility(View.INVISIBLE);
|
||||||
mRecordLed.setVisibility(View.INVISIBLE);
|
mRecordLed.setVisibility(View.INVISIBLE);
|
||||||
@ -294,7 +284,14 @@ public class MediaRecorderActivity extends Activity implements
|
|||||||
|
|
||||||
redoButton.setVisibility(View.VISIBLE);
|
redoButton.setVisibility(View.VISIBLE);
|
||||||
okButton.setVisibility(View.VISIBLE);
|
okButton.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void preview() throws IOException {
|
||||||
|
File file = new File(mMediaObject.getOutputTempTranscodingVideoPath());
|
||||||
|
if(!file.exists() || file.length() == 0){
|
||||||
|
Toast.makeText(this,"录制失败",3000).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(mPlayer == null){
|
if(mPlayer == null){
|
||||||
mPlayer = new MediaPlayer();
|
mPlayer = new MediaPlayer();
|
||||||
mPlayer.setOnCompletionListener(this);
|
mPlayer.setOnCompletionListener(this);
|
||||||
@ -325,6 +322,9 @@ public class MediaRecorderActivity extends Activity implements
|
|||||||
|
|
||||||
|
|
||||||
private void redo(){
|
private void redo(){
|
||||||
|
mCameraSwitch.setEnabled(true);
|
||||||
|
mRecordLed.setEnabled(true);
|
||||||
|
|
||||||
MediaObject.MediaPart part = mMediaObject.getCurrentPart();
|
MediaObject.MediaPart part = mMediaObject.getCurrentPart();
|
||||||
if (part != null) {
|
if (part != null) {
|
||||||
if (part.remove) {
|
if (part.remove) {
|
||||||
@ -439,7 +439,7 @@ public class MediaRecorderActivity extends Activity implements
|
|||||||
this.completed = true;
|
this.completed = true;
|
||||||
Log.d("onEncodeComplete");
|
Log.d("onEncodeComplete");
|
||||||
try {
|
try {
|
||||||
setPreviewUI();
|
preview();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -514,7 +514,7 @@ public class MediaRecorderActivity extends Activity implements
|
|||||||
Log.d("onRecordFinishedListener:拍摄完成");
|
Log.d("onRecordFinishedListener:拍摄完成");
|
||||||
startState = false;
|
startState = false;
|
||||||
stopRecord();
|
stopRecord();
|
||||||
this.mRecordController.setVisibility(View.INVISIBLE);
|
setPreviewUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user