在我的按钮上,我有以下代码:
Log.i(TAG, "!isFirstVideo: " + isFirstVideo);
ConcatenateVideos concatenateVideos = new ConcatenateVideos();
concatenateVideos.setUris(firstVideoUri, fileUri, VideoRecorderActivity.this);
这是我的异步任务类:
public class ConcatenateVideos extends AsyncTask<String, Void, String> {
private String firstVideoUri, fileUri;
private VideoRecorderActivity videoRecorderActivity;
public void setUris(String firstVideoUri, String fileUri, VideoRecorderActivity videoRecorderActivity) {
Log.i("VideoRecorderActivity", "set uris");
this.firstVideoUri = firstVideoUri;
this.fileUri = fileUri;
this.videoRecorderActivity = videoRecorderActivity;
this.execute();
Log.i("VideoRecorderActivity", "set uris2");
}
@Override
protected String doInBackground(String... params) {
Log.i("VideoRecorderActivity", "concat do in background");
FileInputStream videoMain = null, videoToAppend = null;
try {
videoMain = new FileInputStream(firstVideoUri);
videoToAppend = new FileInputStream(fileUri);
} catch (FileNotFoundException e) {
Log.i("VideoRecorderActivity", "concat file not found " + e);
e.printStackTrace();
}
if (videoMain != null && videoToAppend != null) {
concatenateVideos(videoMain, videoToAppend);
videoRecorderActivity.deleteCancelledRecording(fileUri);
}
return null;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
VideoRecorderActivity.recordButton.setEnabled(true);
VideoRecorderActivity.okButton.setEnabled(true);
VideoRecorderActivity.mySurfaceView.setEnabled(true);
Toast.makeText(videoRecorderActivity, "Video appended succesfully", Toast.LENGTH_SHORT).show();
Log.i("VideoRecorderActivity", "concat touche enabled record, ok ,surface: " + VideoRecorderActivity.recordButton.isEnabled() + "| " + VideoRecorderActivity.okButton.isEnabled() + "|" + VideoRecorderActivity.mySurfaceView.isEnabled());
}
在 logcat 我得到:
04-11 12:21:42.520: I/VideoRecorderActivity(7927): set uris
04-11 12:21:42.520: I/VideoRecorderActivity(7927): set uris2
但我不明白Log.i("VideoRecorderActivity", "concat do in background");
这是 doInBackground 类的第一行,在这两行之间被称为:
Log.i("VideoRecorderActivity", "set uris");
this.firstVideoUri = firstVideoUri;
this.fileUri = fileUri;
this.videoRecorderActivity = videoRecorderActivity;
this.execute();
Log.i("VideoRecorderActivity", "set uris2");
任何想法我做错了什么?